有以下程序: #include<stdio.h> main() {int n,*p=NULL; *p=&n; printf("Input n:");seanf("%d",&p);prinff("output n:");printf("%d\n",p); }

admin2021-04-28  24

问题 有以下程序:
#include<stdio.h>
main()
{int n,*p=NULL;
*p=&n;
printf("Input n:");seanf("%d",&p);prinff("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)。
转载请注明原文地址:https://kaotiyun.com/show/CHtp777K
0

最新回复(0)