选择题
36.
有以下程序:
#include<stdio.h>
main()
{
int n,*p=NULL;
*p=&n;
printf("Input n:");
scanf("%d",&p);
printf("output n:");
printf("%d\n",p);
}
该程序试图通过指针p为变量n读入数据并输出,但程序有多处错误,下列语句中正确的是______。
A、
int n, *p=NULL;
B、
*p=&n;
C、
scanf(*%d*,&p)
D、
printf(*%d\n*,p);
【正确答案】
A
【答案解析】
选项B的正确写法应为“p=&n”;选项C的正确写法应为“scanf("%d",p)”;选项D的正确写法应为“printf("%d\n",*p)”。
提交答案
关闭