Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site birtch.UUCP Path: utzoo!decvax!decwrl!pyramid!hplabs!oliveb!felix!birtch!ken From: ken@birtch.UUCP (Ken B) Newsgroups: net.lang.c,net.micro.att Subject: Why doesn't this work? (3B2 problem) Message-ID: <276@birtch.UUCP> Date: Thu, 20-Mar-86 16:40:16 EST Article-I.D.: birtch.276 Posted: Thu Mar 20 16:40:16 1986 Date-Received: Sat, 22-Mar-86 07:58:56 EST Distribution: na Organization: Birtcher, Santa Ana, Calif. Lines: 56 Xref: decwrl net.lang.c:8047 net.micro.att:1054 We have a 3B2/300, and I wrote this program to help debug our spooler problem (another story), why doesn't it work? It never read's an EOF from stdin, and continues to dump 'nulls' to stdout. (Note: I'm just learning 'c', so please no flames on programming style, or lack of it) All the program does is number each line it reads from stdin. --------- code follows --------- #include main() { int i=1; char c; c=getchar(); if (c!=EOF) printf("%d ",i++); while (c!=EOF) { putchar(c); if (c=='\n') { c=getchar(); if (c!=EOF) printf("%d ",i++); } else c=getchar(); } putchar(EOF); } ------ end of code ------ The system is running Sys V un*x, if that helps. The program works, except that it never stops running. I am forced to interrupt it, which writes the data out, with alot of nulls on the 'last line'. Am I doing something wrong? This exact program works correctly on our Pyramid 90x, so I know its not just my program. If anyone out there has some ideas on why it doesn't ever read an EOF, I'd be very grateful to know why. Note: how I use it is: ls -la /bin | number > outputfile or ls -la /bin | number Niether method works correctly (i.e. stops executing) Thank you, Ken Brown -- uucp: ...{!glacier!oliveb,!ihnp4!trwrb} !felix!birtch!ken These ramblings are my own, and are surely not those of my employer.