Does fgets(3) really work right?
brad at bradley.UUCP
brad at bradley.UUCP
Mon Mar 21 12:04:00 AEST 1988
A student here pointed this out to me, is this a bug? I checked
it out on our 3B15 (V5), VAX 11/750 (4.3) and IBMPC (VENIX/86 2.0).
you check the output, should we not get 15 chars on the first
line? Mine prints the whole thing.
========cut here for file named "in"=========
12345678901234567890
12345
aaaaa
========cut here for "temp.c"=============
#include <stdio.h>
main()
{
char str[15], *cp;
FILE *fp;
fp = fopen("in","r");
while((cp = fgets(str, 15, fp)) != NULL)
printf("%s", str);
fclose(fp);
exit(0);
}
More information about the Comp.unix.wizards
mailing list