Hi guys,
I've just read the FAQ about NOT to use feof(fp) to check if we reached the end of the file.
It all make sense but I don't understand 1 thing...
Code:
while (!feof(fp))
{
fgets(buf, sizeof(buf), fp);
printf ("Line %4d: %s", i, buf);
i++;
}
How come that when we reach the end of the file and the fgets return NULL, buf keep its last value... Why fgets doesn't assign buf as NULL and return NULL, it seems that it only return NULL without modifying buf.... Is that how it should be??
Many thanks !!!