#include <fstream> #include <iostream> using namespace std; int main () { try{ char buffer[256]; ifstream myfile ("test.txt"); while (! myfile.eof() ) { myfile.getline (buffer,100); cout << buffer << endl; } }catch(...){ cout << "There was an error !\n"; } return 0; }
This outputting a line.