首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include<stdio.h> #include<string.h> main( ) { char p[20]={’a’,’b’,’c’,’d’},q[]="abc",r[]="abcde"; strcat(p,r); strcpy(p+
有以下程序: #include<stdio.h> #include<string.h> main( ) { char p[20]={’a’,’b’,’c’,’d’},q[]="abc",r[]="abcde"; strcat(p,r); strcpy(p+
admin
2018-06-28
29
问题
有以下程序:
#include<stdio.h>
#include<string.h>
main( )
{
char p[20]={’a’,’b’,’c’,’d’},q[]="abc",r[]="abcde";
strcat(p,r);
strcpy(p+strlen(q),q);
prinff("%d\n",strlen(p));
}
程序的运行结果是( )。
选项
A、11
B、9
C、6
D、7
答案
C
解析
strcpy:字符串复制函数;strlen:求字符串长度函数(注意:不包含字符串结束标记字符’\0’);strcat:字符串连接函数。执行完语句strcat(p,r);后,p数组中存储的元素为a,b,c,d,a,b,c,d,e;执行语句strcpy(p+strlen(q),q);得到的结果是将q所指向的字符串复制至p+strlen(q)开始的存储位置,因为strlen的值为3,即p+3开始存储q中的元素,所以执行完strcpy(p+strlen(q),q)语句后,字符数组p[20]的存储元素为a,b,c,
转载请注明原文地址:https://kaotiyun.com/show/2Rxp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下程序的结果是______。inta,b;voidfun(){a=100;b=200;}main(){inta=5,b=7;fun();printf("%d
数字字符0的ASCII值为48,运行以下程序的输出结果是()。main(){chara=’1’,b=’2’;printf("%c,",b++);printf("%d\n",b-a);}
若变量x、y已定义为int类型且x的值为99,y的值为9,请将输出语printf(【】,x/y);补充完整,使其输出的计算机结果形式为:x/y=11。
设有如下宏定义#defineMYSWAP(z,x,y){z=x;x=y;y=z;}以下程序段通过宏调用实现变量a,b内容交换,请填空。floata=5,b=16,c;MYSWAP(【】a,b);
已有定义如下:structnode{intdata;structnode*next;}*p;以下语句调用malloc函数,使指针p指向一个具有stmctnode类型的动态存储空间。
设有如下定义structss{charname[10];intage;charsex;}std[3],*p=std;下列各输入语句中错误的是_______。
随机试题
假定一个循环队列的队头和队尾指针分别为P和q,则判断队空的条件为_________。
A、大黄酸B、大黄素C、芦荟大黄素D、大黄酚E、大黄素葡萄糖苷易溶于热水的是
氧瓶燃烧可用于
地下水环境影响评价工作中,当I类建设项目位于基岩地区时,一级评价以同一地下水文地质单元为调查评价范围,二级评价原则上以同一地下水水文地质单元或()为调查评价范围。
海因里希将事故连锁过程分为()。
采用封闭式运作方式的基金具有如下特征()。
手表定律:指一个人拥有两只走时不一致的手表时反而会失去判定准确时间的信心,用以比喻同时面对几种不同的工作目标或价值观念等时,人的工作和生活可能会陷入混乱。下列不属于手表定律的是()。
文本框Text1的KeyDown事件过程如下:PrivateSubText1_KeyDown(KeyCodeAsInteger,ShiftAsInteger) ...EndSub其中参数KeyCode的值表示的是发生此事件时(
A、96dollars.B、36dollars.C、60dollars.D、48dollars.C
Asubjectwhichseemstohavebeeninsufficientlystudiedbydoctorsandpsychologistsistheinfluenceofgeographyandclimate
最新回复
(
0
)