Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!eos!aurora!labrea!rutgers!iuvax!pur-ee!uiucdcs!bradley!brad From: brad@bradley.UUCP Newsgroups: comp.unix.wizards Subject: Does fgets(3) really work right? Message-ID: <10900013@bradley> Date: 21 Mar 88 02:04:00 GMT Lines: 24 Nf-ID: #N:bradley:10900013:000:530 Nf-From: bradley.UUCP!brad Mar 20 20:04:00 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 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); }