void testFunc(int);
int main(int argc, char** argv) {
testFunc(1);
testFunc(2);
testFunc(3);
return (EXIT_SUCCESS);
}
void testFunc(int another)
{
int num;
printf("num: %i\n", num);
num = another;
}
輸出: 編號:127383283 人數:1 人數:2爲什麼這個非靜態變量通過函數調用保持其值?
如果我打印變量之前我就每次分配到的東西,我不應該總是得到無用值沒有static關鍵字?
這是未定義的行爲,不要浪費你的時間試圖推斷破碎的代碼。 – Blastfurnace