🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #479

Re: A question about the tertiary (? : ) operator

#479
From: John F. Haugh II
Date: Tue, 22 Aug 1989 13:28
21 lines
1359 bytes
In article <612@cybaswan.UUCP> iiitsh@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@rpp386.cactus.org         |  "If Bill Vajk can do it, anyone can"
UUCPNet:  {texbell|bigtex}!rpp386!jfh   +---------     -- Patricia O Tuama-----
Technical Details
Message-ID: <16928@rpp386.Dallas.TX.US>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!natinst!rpp386!jfh
References: <612@cybaswan.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!natinst!rpp386!jfh
From: jfh@rpp386.Dallas.TX.US (John F. Haugh II)
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: A question about the tertiary (? : ) operator
Message-ID: <16928@rpp386.Dallas.TX.US>
Date: 22 Aug 89 13:28:44 GMT
References: <612@cybaswan.UUCP>
Reply-To: jfh@rpp386.cactus.org (John F. Haugh II)
Followup-To: comp.lang.c
Organization: TrishTrash Readers, Inc.
Lines: 21