TO C OR NOT TO *C
Blair P. Houghton
bph at buengc.BU.EDU
Wed Oct 25 13:33:11 AEST 1989
In article <585 at chem.ucsd.EDU> tps at chem.ucsd.edu (Tom Stockfisch) writes:
>In article <3775 at condict.cs.vu.nl> condict at 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."
More information about the Comp.lang.c
mailing list