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...
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??
fgets(buf, sizeof(buf), fp);
printf ("Line %4d: %s", i, buf);
Many thanks !!!