EOF considered harmful

Peter da Silva peter at ficc.uu.net
Tue Oct 24 03:45:26 AEST 1989


> 	while ( ! feof(stdin) ) {
> 		ch= getchar();
> 		putchar(ch);
> 	}

> 5) Although, to my mind, the above is a compelling argument to abandon the
>    explicit test for EOF, everyone reading this newsgroup (except me of
>    course :-) ) will ignore it!

The fact that it appends a 0xFF byte to the output is, of course, quite
irrelevant.

I did exactly the same thing (though in a much more complex loop) about
eight years ago. It didn't take more than 15 minutes to find it, but I'd
already posted the program on a local CP/M bulletin board so it took a
little longer to get over the embarrasment. If CP/M didn't use ^Z as EOF
it would have been a much quicker fix.
-- 
Peter da Silva, *NIX support guy @ Ferranti International Controls Corporation.
Biz: peter at ficc.uu.net, +1 713 274 5180. Fun: peter at sugar.hackercorp.com. `-_-'
"I feared that the committee would decide to go with their previous        'U`
 decision unless I credibly pulled a full tantrum." -- dmr at alice.UUCP



More information about the Comp.lang.c mailing list