J
John
Hello all,
I am trying to read in lines into a buffer from a file. Normally I would do
this very low-level,
but I have come to the conclusion I must stop doing everything the hard way.
So, I thought I would try
<fstream>. The code below causes an infinite loop in the while() statement.
Debugging, I see that the buffer just has a 0 in
the first position, and nothing else.
ifstream listfile;
listfile.open("data\\modellist.txt", ios::in);
if(listfile.bad()) return 0;
char buffer[100];
while(!listfile.getline(buffer, 100).eof())
{
//Do stuff with buffer
}
Anyone know why? The file is ok, and works fine with fread and the like.
Thanks in advance!
I am trying to read in lines into a buffer from a file. Normally I would do
this very low-level,
but I have come to the conclusion I must stop doing everything the hard way.
So, I thought I would try
<fstream>. The code below causes an infinite loop in the while() statement.
Debugging, I see that the buffer just has a 0 in
the first position, and nothing else.
ifstream listfile;
listfile.open("data\\modellist.txt", ios::in);
if(listfile.bad()) return 0;
char buffer[100];
while(!listfile.getline(buffer, 100).eof())
{
//Do stuff with buffer
}
Anyone know why? The file is ok, and works fine with fread and the like.
Thanks in advance!