Advertisement

ifstream stuff

Started by March 23, 2000 05:51 PM
4 comments, last by C++ Freak 24 years, 7 months ago
what function do you use with an ifstream object to read a line of text from a file?and does it know to go to the next line if you use it again? Visit http://members.xoom.com/ivanickgames
Visit http://members.xoom.com/ivanickgames
ifstream infile;
infile.open("blah.dat", ios::in);
char buff[255];

infile >> buff;

it reads the data from a text file, and when it encounters the new line character it advances to the next line.
Advertisement
Couldn''t you also use istream::getline()?
hrm.. I''ve never used it myself, but more than likely you could.
I found that >> did all that I needed, so I just stuck with that.
Aztec,
Actually doing what you did will stop at the first whitespace, so if you want to get the entire line, you should use getline().

-Brian
OH REALLY!
okey dokey, I''ve not used it that extensively
thanks for clarifying that

This topic is closed to new replies.

Advertisement