//*************************************************************************************** // C++ Read data from a file //*************************************************************************************** #include #include #include using namespace std; int main() { string line; try { ifstream infile("db/student"); //open file while (getline(infile, line)) //iterate thru the lines in the file { cout << line; } infile.close(); //close file } catch (const exception &e) { cout << "ERROR: Exception in " << __FILE__; cout << "(" << __FUNCTION__ << ") on line (" << __LINE__ << ") " << e.what() << endl; } return EXIT_SUCCESS; }