有以下程序
#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);
第1题:
有以下程序 #include <stdio.h> void fun(char **p) { ++p; printf("%s\n",*p); } main() { char *a[]={"Moming","Afternoon","Evening","Night"}; fun(a); } 程序的运行结果是
A.Afternoon
B.fternoon
C.Morning
D.orning
第2题:
有以下程序
include<stdio.h>
int*f(int*p,int*q);
main( )
{int m=1,n=2,*r=&m;
r=f(r,&n);printf(”%d\n”,*r);
}
int-f(int*P,int*q)
(return(*p>*q)?p:q;)
程序运行后的输出结果是______。
第3题:
有以下程序 #include.<string.h> main() { char *p="abcde\ofghjik\0"; printf("%d\n",strlen(p)); } 程序运行后的输出结果是
A.12
B.15
C.6
D.5
第4题:
有以下程序 #include<stdio.h> void f(int *p,int *q); main() { int m=1,n=2,*r=&m; f(r, &n); printf("%d,%d",m,n); } void f(int*p,int*q) {p=p+1; *q=*q+1;) 程序运行后的输出结果是______。
A.1,3
B.2,3
C.1,4
D.1,2
第5题:
有以下程序 #include <stdio.h> #include <stdlib.h> int fun(int n) {int *p; p=(int*)malloc(sizeof(int)); *p=n; return *p; } { int a; a=fun(10); printf("%d\n",a+fun(10)); } 程序的运行结果是______。
A.0
B.10
C.20
D.出错