2
int x=10;  
int y=5; 
printf("%d",(y,x));

So, here's this code. This code prints 10 when run. I'd like to know how it does so. Specifically, what the comma and parenthesis are doing in the printf statement.

  • 1
    in this case "`,` is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type)." -[Wikipedia](http://en.wikipedia.org/wiki/Comma_operator) – turbulencetoo Mar 05 '14 at 20:23
  • 1
    Just realized it is a *C* question, this is a better dup: [What does the comma operator `,` do in C?](http://stackoverflow.com/questions/52550/what-does-the-comma-operator-do-in-c) ... although the answer is essentially the same. Retracted vote though, wish I could switch which dup I choose. – Shafik Yaghmour Mar 05 '14 at 20:25

0 Answers0