Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site basser.SUN Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!floyd!harpo!decvax!mulga!munnari!basser!chris From: chris@basser.SUN (Chris Maltby) Newsgroups: net.unix-wizards Subject: Re: getc() != EOF Message-ID: <307@basser.SUN> Date: Wed, 30-May-84 12:28:01 EDT Article-I.D.: basser.307 Posted: Wed May 30 12:28:01 1984 Date-Received: Fri, 1-Jun-84 06:28:13 EDT References: <30@utastro.UUCP> Organization: Dept of C.S., University of Sydney Lines: 25 [] > > > >In all conscience, > > > > while ( (c = getc()) != EOF ) > > > >ought to work. If somebody is to be blamed, it is surely not the > >people who wrote the code, but the people who made a C implementation > >that broke it. > > It will work if "c" is declared "int." > It will not work if "c" is declared "char." > > Variable declarations are an essential part of the program, and should be > included in illustrative code fragments, so problems are not concealed. > > Ed Nather WRONG! The code above will work if c is int or char. Char variables are promoted to int in expressions (see C manual) and a char -1 is IDENTICAL with an int -1. Unsigned char c could be different (Any C implementors there? (kvm?)). Chris Maltby University of Sydney