Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!rpi!batcomputer!lacey From: lacey@batcomputer.tn.cornell.edu (John Lacey) Newsgroups: comp.lang.c Subject: Re: use of if (!cptr) and if (cptr), where cptr is a * Message-ID: <8468@batcomputer.tn.cornell.edu> Date: 21 Jul 89 05:55:11 GMT References: <10099@mpx2.mpx.com> <93@microsoft.UUCP> <10100@mpx2.mpx.com> <10103@mpx2.mpx.com> Reply-To: lacey@tcgould.tn.cornell.edu (John Lacey) Organization: Cornell Theory Center, Cornell University, Ithaca NY Lines: 50 In article <10103@mpx2.mpx.com> erik@mpx2.mpx.com (Erik Murrey) writes: [Material everybody has seen n times deleted.] >Perhaps my example was bad. The above coding method is >even more useful in while() and for() loops: > >while (cc= fgetc(fp), cc != '\n') { > /* process more of line */ > ... >} > >or even: > >while (myptr= my_func(), myptr->x != myptr->y) { > /* ... */ > ... >} > >I would kinda like to see that one in your style... > I am kind of butting in [ :-) ], but how 'bout while ( (cc = fgetc(fp)) != '\n' ) { : } and while ( ( myptr = my_func() )->x != myptr->y ) { : } or even for ( myptr = my_func(); myptr->x != myptr->y; myptr = my_func() ) { : } though I use the last most commonly only when the two functions (primer and `incrementer') are different. Just a personal beef, maybe, but the comma operator slows me down when I'm reading code, and these example here don't. -- John Lacey | cornell!batcomputer!lacey lacey@tcgould.tn.cornell.edu | lacey@crnlthry.bitnet