On Wed 2009-11-25 14:48:42 UTC-0000, johnmatthews2000 ([email protected]) wrote:
> If fgets() on a FILE* returns 0 indicating end-of-file, is it safe to
> call it again? That is, is it guaranteed that the function will return
> 0 again with no undesirable side effects?
fgets() returns a pointer, not an integer.
What are you trying to achieve?
Normally you'd do something like:
#define BUFSIZE 512
char s[BUFSIZE], *p;
p = fgets(s, sizeof s, fp);
while (p != NULL)
{
print("%s", p);
p = fgets(s, sizeof s, fp);
}
if (ferror(fp))
{
/* something bad happened! */
/* ... */
}