Returning a variable while using a post increment in C
问题 I have a global variable called var and a function foo . (I know it's a bad practice but sometimes it's unavoidable) I'm wondering if the C standard (I'm compiling using c99) says what happens to var if I try to execute: long foo(){ return var++; } Thanks. 回答1: Short answer: It will return a copy of var and then immediately afterwards increment the global var . Long answer: C11 6.5.2.4 "The result of the postfix ++ operator is the value of the operand. As a side effect, the value of the