Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!husc6!rice!sun-spots-request From: stanonik@nprdc.navy.mil (Ron Stanonik) Newsgroups: comp.sys.sun Subject: fscanf bug? Keywords: SunOS Message-ID: <326@brazos.Rice.edu> Date: 20 Jul 89 07:00:00 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 42 Approved: Sun-Spots@rice.edu X-Sun-Spots-Digest: Volume 8, Issue 80, message 11 of 15 Or maybe it's a feature? But it was news to me. I believe we've encountered an fscanf bug in sunos4.0.1 on sun4's, sun3's, and sun386i's. The apparent bug is that given a control string of "%c", fscanf returns 0, rather than EOF on encountering the end of file. Here's a sample program: #include main() { int i; char c; for (i = 5; i > 0; i--) { printf("cnt=%d\n", fscanf(stdin, "%c", &c)); printf("%x\n", c); } } Here's a sample file: ab Here's the result: arctic[244] t < a cnt=1 31 cnt=1 33 cnt=1 a cnt=0 a cnt=0 a Back in sunos3.5 days, the 0 cnt's would be -1 (ie, EOF), as expected. Ron Stanonik stanonik@nprdc.navy.mil