Home > Back-end >  This program who can understand, who can explain what is the meaning of this program? To solve the
This program who can understand, who can explain what is the meaning of this program? To solve the

Time:09-25

#include
Int fun (intA)
{
Int b=0;
Static int c=3;
A=(c + +, b++);
Return (a);
}
The main ()
{
Int a=2, I, k;
for (i=0; i<2; I++)
K=fun (+);
Printf (" % d \ n ", k);
}

CodePudding user response:

The program is wrong:
Int fun (intA)
And
A=(c + +, b++);//a undefined

CodePudding user response:

The results should be
0
0

CodePudding user response:

The output is 0
The key is a=(c + +, b++); This sentence, the order of the comma operator is like this:
1, c and b values, participate in the comma operator operation, return the value of b to a
2, the implementation of c + 1 and + 1 b
Because b is temporary variables, each function call is initialize 0, so no matter what you a parameter incoming, comma operators always return the value of b



  • Related