6
9
11
7
第1题:
有以下程序
#include
main()
{char p[20]={‘a’,’b’,’c’,’d’},q[]=”abc”, r[]=”abcde”;
strcpy(p+strlen(q),r); strcat(p,q);
printf(“%d%d\n”,sizeof(p),strlen(p));
}
程序运行后的输出结果是( )。
A.20 9
B.9 9
C.20 11
D.11 11
第2题:
有以下程序:
include<strintg.h>
main
{ char p[20]={a,b,c,d),q[]="abc",r[]="
abcde";
strcpy(p+strlen(q),r);strcat(p,q);
printf("%d%d\n",sizeof(p),strlen(p));
}
程序运行后的输出结果是( )。
A.20 9
B.9 9
C.20 11
D.11 11
在主函数中,首先定义一个包含20个元素的字符数组P,执行语句“strcpy(P+strlen(q),r);”,数组P的内容变为{a,b,C,a,b,c,d,e,\0,\0,\0,\0,\0,\0,\0,\0,\0,\0,\0,\0),执行语句“strcat(P,q);”,数组P的内容变为,a,b,c,a,b,C,d,P,a,b,c,\0,\0,\0,\0,\0,\0,\0,\0),函数sizeof(P)是求数组P的大小,返回20,而函数strlen (p)是计算以P所指起始地址的字符串的长度,这一长度不包括串尾的结束标志0,所以函数返回11。
第3题:
有以下程序
#include <string.h>
main( )
{ char p[20]={'a','b','c','d'},q[]="abc", r[]="abcde";
strcpy(p+strlen(q),r); strcat(p,q);
printf("%d%d\n",sizeof(p),strlen(p));
}
程序运行后的输出结果是
A)20 9
B)9 9
C)20 11
D)11 11
第4题:
有以下程序: # include<stdio.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.abe d
D.d d
第5题:
有以下程序 #include<string.h> main() { char p[20]={'a','b','c','d'},q[]="abc",r[]="abcde"; strcat(p,r);strcpy(p+strlen(q),q); printf("%d\n",strlen(p)); } 程序运行后的输出结果是
A.9
B.6
C.11
D.7
第6题:
有以下程序
#include
main()
{char p[20]={‘a’,’b’,’c’,’d’},q[]=”abc”, r[]=”abcde”
strcat(p,r); Strcpy(p+strlen(q),q);
Printf(“%d \n”,sizeof(p));
}
程序运行后的输出结果是( )。
A.9
B.6
C.11
D.7
第7题:
有以下程序 #include<string.h> main() { char p[20]={'a','b','c','d'},q[]="abc",r[]="abcde"; strcpy(p+strlen(q),r);strcat(p,q); printf("%d%d\n",sizeof(p),strlen(p)); } 程序运行后的输出结果是
A.20 9
B.9 9
C.20 11
D.11 11
第8题:
有以下程序
#include <string.h>
main( )
{ char p[20]={ 'a', 'b', 'c', 'd'},q[]="abc", r[]="abcde"
strcat(p,r); s trcpy(p+strlen(q),q);
p rintf("%d\n", strlen (p));
}
程序运行后的输出结果是
A)9
B)6
C)11
D)7
第9题:
有以下程序: #include<string.h> main() {char p[20]={'a','b','c','d'),q[]="abc",r[]="abcde" strcat(p,r);strcpy(p+strlen(q),q); printf("%d\n",sizeof(p)); } 程序运行后的输出结果是( )。
A.9
B.6
C.11
D.7
第10题:
若有以下程序段:
include <iostream>
using namespace std;
int main()
{
char*p="abcdefgh",*r;
long*q;
q=(long*)p;q++;
r=(char*)q;
cout<<r<<end1;
return 0;
}
该程序的输出结果是【 】。