Re: compare a large number of variables



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.
.