C++ examples for File Stream:stream
Read string from file
#include <fstream> #include <iostream> using namespace std; int main()//from w ww .java2 s. com { const int MAX = 80; //size of buffer char buffer[MAX]; //character buffer ifstream infile("TEST.TXT"); //create file for input while( !infile.eof() ) //until end-of-file { infile.getline(buffer, MAX); //read a line of text cout << buffer << endl; } return 0; }