有以下程序 #include main() {int n,*p=NULL; *p=&n; pr*ntf("Input n:"); scanf("%d",&p); printf("output n:

admin2019-12-17  26

问题 有以下程序
    #include
    main()
    {int n,*p=NULL;
    *p=&n;
    pr*ntf("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

解析 选项A)表示在程序中,声明定义变最语句“int n,*p=NULL;”定义了整型变量n和指针变量p,并且指针变量p初始化为空。其他的语句都是错误的。其中选项B),&n的地址应存放到指针变量p中,而选项C)中数据输入项错误.选项D)输出地址信息。
转载请注明原文地址:https://kaotiyun.com/show/ZQCp777K
0

最新回复(0)