可能重複:
Parameter evaluation order before a function calling in C錯誤輸出,同時運行C語言代碼
對於下面的代碼我期望的輸出爲20和76,而是75和21正在添加作爲輸出。請解釋爲什麼是這樣。
#include<stdio.h>
unsigned func(unsigned n)
{
unsigned int a =1 ;
static unsigned int b=2;
a+=b; b+=a;
{
unsigned int a=3;
a+=b; b+=a;
}
//printf("%d %d ",a,b);
return (n+a+b);
}
int main()
{
printf("%d %d\n",func(4),func(5));
return 0;
}
我還沒有證實,但我強烈懷疑這一點:http://stackoverflow.com/questions/376278/parameter-evaluation-order-before-a-function-calling-in-c – Mysticial