Path: utzoo!attcan!uunet!mcvax!hp4nl!htsa!fransvo From: fransvo@htsa.uucp (Frans van Otten) Newsgroups: comp.lang.c Subject: Re: Always use braces Message-ID: <683@htsa.uucp> Date: 3 Jan 89 08:27:20 GMT References: <5@rsoft.UUCP> <1071@goofy.megatest.UUCP> <861@quintus.UUCP> <271@twwells.uucp> <11037@ulysses.homer.nj.att.com> <9235@smoke.BRL.MIL> Reply-To: fransvo@htsa.UUCP (Frans van Otten) Organization: AHA-TMF (Technical Institute), Amsterdam Netherlands Lines: 31 In article <9235@smoke.BRL.MIL> gwyn@brl.arpa writes: > #include > #define MAGIC '\0' /* silly terminating character value */ > int /* returns EOF or MAGIC (why??) */ > some_function( void ) /* ANSI C assumed; else delete "void" */ > { > int c; /* character from standard input */ > while ( (c = getchar()) != EOF ) > if ( c == MAGIC ) > return MAGIC; > return EOF; > } How do you like it my way: #include int f() { int ch; while ((ch = getchar()) != EOF && c) /* find EOF or '\0' */ return (ch); } Any C programmer will understand how this function works; it takes less space, because it is shorter, etc. So: Why is my solution too simple ? -- Frans van Otten Algemene Hogeschool Amsterdam Technische en Maritieme Faculteit fransvo@htsa.uucp