Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!tut.cis.ohio-state.edu!purdue!bu-cs!buengc!bph From: bph@buengc.BU.EDU (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: TO C OR NOT TO *C Message-ID: <4644@buengc.BU.EDU> Date: 25 Oct 89 03:33:11 GMT References: <16107@nswitgould.cs.uts.oz> <1989Oct16.172249.18387@utzoo.uucp> <991@cirrusl.UUCP> <3775@condict.cs.vu.nl> <585@chem.ucsd.EDU> Reply-To: bph@buengc.bu.edu (Blair P. Houghton) Followup-To: comp.lang.c Organization: Boston Univ. Col. of Eng. Lines: 33 In article <585@chem.ucsd.EDU> tps@chem.ucsd.edu (Tom Stockfisch) writes: >In article <3775@condict.cs.vu.nl> condict@cs.vu.nl (Michael Condict) writes: >>This problem can be gotten around in C, using the ',' operator: >> >> while (c = getc(stdin), !feof(stdin)) { >> .. do stuff with c .. >> } > >This doesn't always work: for instance, if the first part is a statement. while ( ! getcandfeof(&c) ) { .. do stuff .. } int getcandfeof( cptr ) char *cptr; { *cptr = getc(stdin); return ( feof(stdin) ); } Any number of statements can be stuffed into the function. It's unfortunate that it adds yet more overhead, though. >On all compilers I work on, there is the additional requirement (the >standard not withstanding) that all operands of the comma operator be >non-void. What a lousy compiler. --Blair "But I mean that in a nice way, I really do."