While it is not the end of a file, output file line by line : File End EOF « File « C++






While it is not the end of a file, output file line by line

  
#include <iostream>
#include <fstream>
using namespace std;
int main () {
 char buffer[256];
 ifstream myfile ("test.txt");
 while (! myfile.eof() )
 {
   myfile.getline (buffer,100);
   cout << buffer << endl;
 }
 return 0;
}
  
    
  








Related examples in the same category

1.Use eof() to read and display a text file.
2.ios::ate places the get-position pointer at the file end, enable tellg() to return the size of the file