Sunday, July 12, 2009

Streamreader visual c++ question!?

I want to read from a text file for my MFC application. I used streamreader but visual studio says it's undeclared.





I tried fstream as well and i'm getting undeclared errors too. Any idea why?





Is streamreader the best way to read a text file line by line? Thanks.

Streamreader visual c++ question!?
well I'm not sure but isn't Streamreader in C#?





If you;re trying to read in a text file then you must include the library %26lt;fstream.h%26gt;





and the line of code is





string line;


ifstream myfile ("example.txt");


while (! myfile.eof() )


{


getline (myfile,line);


cout %26lt;%26lt; line %26lt;%26lt; endl;


}


myfile.close();


}


No comments:

Post a Comment