B
boa
* Markus Pitha wrote, On 20.08.2006 15:01:
It isn't, see the faq for details. http://c-faq.com/stdio/feof.html
ffffffff happens to be the same as -1 on most machines. EOF also happens
to be -1 on most machines. So you're printing the value of EOF, returned
from fgetc(). On the next iteration, feof() returns true and your loop
stops.
boa
Hello,
I read a simple bmp-file with this loop:
while ( !feof(fp) ) {
printf("%x\n", fgetc(fp));
}
fclose(fp);
Everything seems to be correct,
It isn't, see the faq for details. http://c-faq.com/stdio/feof.html
but at the end of the file, I get a weird
"ffffffff" output. How does this come? Actually the loop must have been
finished before printf can print some data, or when will the file
pointer increased in this case?
ffffffff happens to be the same as -1 on most machines. EOF also happens
to be -1 on most machines. So you're printing the value of EOF, returned
from fgetc(). On the next iteration, feof() returns true and your loop
stops.
boa