首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include #include main() { char p[20]={’a’, ’b’, ’c’, ’d’}, q[]="abc", r[]="abcde"; strcat(p, r);strcpy(p+strlen(q), q)
有以下程序 #include #include main() { char p[20]={’a’, ’b’, ’c’, ’d’}, q[]="abc", r[]="abcde"; strcat(p, r);strcpy(p+strlen(q), q)
admin
2015-07-31
19
问题
有以下程序
#include
#include
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、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, a,b,c;所以strlen(p)的结果为6。因此C选项正确。
转载请注明原文地址:https://kaotiyun.com/show/CoDp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
将E-R图转换到关系模式时,实体与实体间的联系可以表示成()。
以下程序的输出结果是______。fun(int*s,int*p){staticintt=3;*p=s[t];t--;}main(){intstr[]={1,2,3,4},i,m=0;
判断字符串s1是否大于字符串s2,应该使用()。
设有如下函数定义,则输出结果为_______。char*fun(char*str){char*p=str;while(*p){if(*p>’d’)continue;p++;}
深度为5的满二叉树中,叶子结点的个数为______。
下列不属于软件工程的3个要素的是()。
下列叙述中不正确的是()。
下列工具中为需求分析常用工具的是()。
一棵二叉树第6层(根结点为第一层)的结点最多为______个。
将E-R图转换到关系模式时,实体与实体间的联系可以表示成()
随机试题
下列诗句不是出自唐朝诗人的是()。
国际政治基本准则的特点:______、______、______、______。
下列现金流量中,属于投资活动产生的现金流量的有()
A.膈肌B.肋间内肌C.肋间外肌D.腹肌E.斜角肌当腹部活动受限时,以上何种肌肉收缩将有助于用力呼气
我国的甲有限责任公司和乙股份有限公司素有业务往来。甲公司的负责人吴某和乙公司的负责人赖某商议,甲公司准备走私一批高级轿车,欲出高额租金租下乙公司的部分仓库以存放走私的轿车。赖某看吴某出的租金很高,就答应了下来。后经人举报,吴某被有关部门查获,并查获了在乙公
某机床生产企业,职工共30人,企业的资产总额为300万元,上年亏损52万元,2019年企业有关生产、经营资料如下。(1)取得产品销售收入230万元,国债利息收入13万元,金融债券利息收入10万元。(2)发生产品销售成本100万元,发生产
下列()是法国艺术家杜米埃创作的。
《幼儿园工作规程》规定,幼儿园应保证幼儿每日户外活动时间不得少于()小时。
A、 B、 C、 A图片A是一个包在椅子后面,图片B是一个盆子在凳子后面,图片C是一件衣服在桌子上面。故本题答案为A。
AutomationThetermautomationwascoinedaround1946bytheautomobileindustrytodescribetheincreaseduseofautomatic
最新回复
(
0
)