Closed. This question is off-topic。它当前不接受答案。
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
5年前关闭。
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
5年前关闭。
int main()
{
int i = 10;
int *p = &i;
foo(&p);
printf ("%d ", *p);
printf ("%d ", *p);
}
void foo(int **const p)
{
int j = 11;
*p = &j;
//Printing the vlue
printf("%d ", **p);
}
最佳答案
返回foo
时,p
中的指针main
指向执行foo
时存在的局部变量。由于foo
已结束,因此取消引用该指针会调用未定义的行为。因此,您的程序可以输出,甚至可以执行任何操作。
关于c - 以下程序的输出是什么? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22279465/