Re: compare a large number of variables
- From: Dietmar Schindler <dSpam@xxxxxxxx>
- Date: Wed, 31 Aug 2005 08:16:30 +0200
Suman wrote:
> #include <stdio.h>
> int main(void)
> {
> int a = 0;
> int b = 3, c = 5, d = 2, e = 6;
> printf("%d\n", a ? b, c : d, e);
> printf("%d\n", a ? (b, c) : (d, e));
> printf("%d\n", (a ? (b, c) : d), e);
> return 0;
> }
> gcc version 4.0.0
> gcc -W -Wall -std=c99 cond.c
> and a few warnings about `left-hand operand of comma expression has no
> effect' later ...
> <output>
> 2
> 6
> 2
> </output>
I have the impression that you are not aware of the first printf
outputting the value of
a ? b, c : d
(which is the same as the last printf), since the comma is not treated
as the operator, but as an argument separator.
.
- References:
- compare a large number of variables
- From: Einar
- Re: compare a large number of variables
- From: Eric Sosman
- Re: compare a large number of variables
- From: Einar
- Re: compare a large number of variables
- From: Netocrat
- Re: compare a large number of variables
- From: Michael Wojcik
- Re: compare a large number of variables
- From: Netocrat
- Re: compare a large number of variables
- From: Michael Wojcik
- Re: compare a large number of variables
- From: Netocrat
- Re: compare a large number of variables
- From: Michael Wojcik
- Re: compare a large number of variables
- From: Netocrat
- Re: compare a large number of variables
- From: Michael Wojcik
- Re: compare a large number of variables
- From: Netocrat
- Re: compare a large number of variables
- From: Richard Bos
- Re: compare a large number of variables
- From: Netocrat
- Re: compare a large number of variables
- From: Dietmar Schindler
- Re: compare a large number of variables
- From: Suman
- compare a large number of variables
- Prev by Date: Re: More questions about casting function pointers ..
- Next by Date: Re: memset doubt
- Previous by thread: Re: compare a large number of variables
- Next by thread: Re: compare a large number of variables
- Index(es):