首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include main() { char p[20]={’a’,’b’,’c’,’d’},q[]="abc",r[]="abcde"; strcat(p,r);strcpy(p+strlen(q),q); printf("%d\n",
有以下程序 #include main() { char p[20]={’a’,’b’,’c’,’d’},q[]="abc",r[]="abcde"; strcat(p,r);strcpy(p+strlen(q),q); printf("%d\n",
admin
2015-12-25
24
问题
有以下程序
#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、9
B、11
C、6
D、7
答案
C
解析
字符串连接函数strcat(p,r)的功能是把字符数组p[]和r[]连接起来,此时字符数组p[]的有效字符长度为9,再执行strcpy(p+strlen(q),q)字符串复制函数,把字符数组q[]复制到字符数组p[]从p[3]开始到p[5]数组位置中,由于字符数组q[]中的内容为字符串“abc”复制时把字符串结束标志’\null’也复制到字符数组p[]中,这时字符函数strlen(p)返回字符数组p[]的有效字符长度为6。
转载请注明原文地址:https://kaotiyun.com/show/GCDp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
阅读下列程序,当运行函数时,输入asdafaaz67,则输出为#include<stdio.h>#include<ctype.h>#inelude<string.h>intfun(char*str)
下列程序的输出结果是()。main(){inta=1,b=2;printf("%d,%d\n",--a,++b);}
在深度为5的满二叉树中,叶子结点的个数为
数据库系统其内部分为三级模式,即概念模式、内模式和外模式。其中,______是用户的数据视图,也就是用户所见到的数据模式。
下列程序中c的二进制值是()。chara=2,b=4,C;c=a^b>>2;
下列程序的运行结果是()。#include<stdio.h>#include<string.h>main(){char*s1="abDuj";char*s2="ABdUG";intt;t
下列程序的输出结果是()。#include<stdio.h>intfun(intx){inta;if(x==0‖x==1)return3;elsea=x-fun(x-2);
下列程序段的输出结果是______。intn=’C’;switch(n++){default:printf("error");break;case’a’:printf("good");break;case’C’
设有定义语句:intx[6]={2,4,6,8,5,7},*p=x,i;要求依次输出x数组6个元素中的值,不能完成此操作的语句是______。
随机试题
MR扫描前的准备工作中,不正确的是
对新生仔畜窒息处理失当的是
甲公司依法取得15亩蔬菜生产基地和城市规划区内20亩国有土地的土地使用权,用于开发商品房和经济适用住房,并委托某房地产估价机构对被拆迁房屋的市场价格进行了评估。开发建设过程中,甲公司依法取得商品房预售许可证后,委托乙公司代理预(销)售商品房,委托协议签订后
在进行地面水环境影响预测时,口外滨海段可视为()。
下列关于詹森指标的说法中,正确的是()。
(2008年考试真题)当事人采用仲裁方式解决纠纷,应当由双方自愿达成仲裁协议。()
有学者探究道光皇帝为什么把他的墓修筑得比其他帝王墓都要矮小。北京师范大学历史学院龚书铎教授说:“是因为‘在他手上打了败仗丢了土地,没有面目见先帝’。”这里所说的“土地”是指()。
三峡工程是治理和开发长江的关键性骨干工程,建成后水库正常蓄水位175米,总库容393亿立方米,具有防洪、发电、航运等巨大的综合效益。工程分为大坝、电站、通航建筑物等几个主要部分。大坝全长2309米,坝顶高185米。电站设有左、右两组共26台单机额定容量为7
•Readthetextbelowabouttelevisionnetwork.•Inmostofthelines41—52thereisoneextraword.Itiseithergrammaticallyi
WiththestartofBBCWorldServiceTelevision,millionsofviewersinAsiaandAmericacannowwatchtheCorporation’snewscov
最新回复
(
0
)