Re: reading a file and outputting it in c++

Posted 28 February 2010 - 12:37 AM

You may want to try this:

ifstream fin;
fin.open(bunFile.c_str());
string line;
// loop until we have lines in the file
while (getline(fin, line))
{
// the getline function from the while loop does the extraction of line too!
// here, only the printing function is needed!
cout << line << endl;
}
fin.close();