A question about the tertiary (? : ) operator
John F. Haugh II
jfh at rpp386.Dallas.TX.US
Tue Aug 22 23:28:44 AEST 1989
In article <612 at cybaswan.UUCP> iiitsh at cybaswan.UUCP (Steve Hosgood) writes:
>I never noticed until last night that the conditional operator:
>
><condition>? <val1>: <val2>
>
>..is not a valid lvalue, even if both <val1> and <val2> are lvalues!
>I wanted to say:
>
>(flag > 0? foo: bar) = <complex expression>;
>
>..which didn't work, needless to say. I had to employ a temporary variable
>and an 'if' statement in the end :-(.
There is a way to do this ...
*((type_of_foobar *) flag > 0 ? &foo:&bar) = <complex expression>
--
John F. Haugh II +-Quote of the month club: ------------
VoiceNet: (512) 832-8832 Data: -8835 | Speaking of Netnews Administration:
InterNet: jfh at rpp386.cactus.org | "If Bill Vajk can do it, anyone can"
UUCPNet: {texbell|bigtex}!rpp386!jfh +--------- -- Patricia O Tuama-----
More information about the Comp.std.c
mailing list