+ 1
C++ COUT with arguments? (a, b, c)
I come along with c++ code using cout with some kind of arguments in parentheses, but only last one was printed out, can somebody please explain why? Thanks. cout << (1,2,3); Output: 3. https://code.sololearn.com/ccCiIoexxXe8/?ref=app
3 Respuestas
+ 5
Nice question.
I got the results when I googled about it.
This is because of comma operator.
Visit the given link for description.
https://stackoverflow.com/questions/28326062/what-is-the-output-of-cout-a-b-and-why
+ 1
Updated code.
all expressions are processed but not used in cout, only the last one.
https://code.sololearn.com/ccCiIoexxXe8/?ref=app
0
Thanks HK. I tried to google this, but was not sure how to define the question.
So I see now, the comma operator is the key. It evaluates all the comma separated value, but result is not used, only the last one.