+ 2
What syntax is this?
Why is the output the last element? What is this syntax and what does it mean? First time I saw this xD https://code.sololearn.com/c1T3Ez1B679t/?ref=app
2 ответов
+ 4
The comma operator does all the expressions in order and then returns the last one. You know, like in
a = 4, b = 5;
The above line also happens to return `5`. It's just code that is meant to look confusing.
+ 2
Schindlabua oh yeah I get it now! Damn thats strange because this actually works:
int main() {
int a, b;
int c = (a = 1, b = 2);
printf("%d %d %d", a, b, c);
return 0;
}
// Output: 1 2 2