0
What is the output and why?
int main() { int i = 1; printf("%d %d %d\n", ++i, i++, i); return 0; }
2 Answers
+ 2
Why do people hate Google?
You can find anything out there. It's definitely one of the greatest achievements in the whole human existence. And yet people ignore it.
I wanted to do a banal search for "c post increment" but I am too dumb to write it correctly at the first try and too lazy to delete and rewrite, so i googled "c postinvrrment" and guess what... Google gave me exactly what I wanted.
I could pick one result randomly knowing that contains what I am looking for, but I like the site stack overflow, so I pick the first result of this site. Here's your answer:
https://stackoverflow.com/questions/4445706/post-increment-and-pre-increment-concept
And in case you haven't learnt to use Google yet, this may be helpful:
https://stackoverflow.com/questions/52550/what-does-the-comma-operator-do
+ 1
Try yourself in code playground