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