use of if (!cptr) and if (cptr), where cptr is a *
John Lacey
lacey at batcomputer.tn.cornell.edu
Fri Jul 21 15:55:11 AEST 1989
In article <10103 at mpx2.mpx.com> erik at 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 at tcgould.tn.cornell.edu | lacey at crnlthry.bitnet
More information about the Comp.lang.c
mailing list