On (23 Sep 97) Rick Svyzek wrote to All...
RS> Hi, I got a problem I been working on. I'm a beginner at C++
RS> programming. What I need help with is how to read a text file line by
RS> line with a program. I can get my program to open a file stream and
RS> it reads the first line then exits. Could someone please point me
RS> into the right direction :)
A while loop is the most common method:
ifstream file("whatever.txt");
char buffer[256];
while ( !file.bad() ) {
file.getline(buffer, 256);
There's also a good() member function, but for better or worse, !bad()
is NOT the same as good(), nor vice versa...
Later,
Jerry.
--- PPoint 2.02
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)
|