有以下程序 #include 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);
第1题:
有以下程序: #include <stdio.h> main( ) { struct node{int n; struct node*next;} *P; struct node x[3]={{2,x+1),{4,x+2},{6,NULL}}; P= X; printf("%d,",p->n); printf("%d\n",p->next->n); } 程序运行后的输出结果是( )。
A.2,3
B.2,4
C.3,4
D.4, 6
第2题:
有以下程序 #include <stdlib.h> main() { char *p,*q; p=(char*)malloc(sizeof(char)*20); q=p; scanf("%s %s",p,q); printf("%s %s\n",p,q); } 若从键盘输入:abc def<回车>, 则输出结果是
A.def def
B.abc del
C.abc d
D.d d
第3题:
若输入“abcdef”“abdef”,下述程序的输出结果为( )。
#include
#include
main
{int n;
char s1[20],s2[20],*p1,*p2;
scanf("%s",s1);
scanf("%S",s2);
p1=s1;
p2=s2;
n=strcmp(p1,p2);
printf("Vood\n",n); }
A.-1
B.0
C."abcdef"
D."abdef"
第4题:
有以下程序 #include<stdlib.h> main() { char*p,*q; p=(char *)malloc(sizeof(char)*20);q=p; scanf(“%s%s”,p,q);printf(“%s%s\n”,p,q); } 若从键盘输入:abc def<回车>,则输出结果是
A.def def
B.abc def
C.abc d
D.d d
第5题:
有以下程序: #include<stdlib.h> main( ) { char *p ,* q; p=(char * )malloc(sizeof(char) * 20);q=p; scanf("%s%s",p,q); printf("%s%s\n",p,q); } 若从键盘输入:abc def<回车>,则输出结果是
A.def def
B.abc def
C.abc d
D.d d