首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include<string.h> main() {char p[20]={’a’,’b’,’,’c’,’d’},q[]==="abc",r[]="abcde"; strcat(p,r);strcpy(p+strlen(q),q); prin
有以下程序 #include<string.h> main() {char p[20]={’a’,’b’,’,’c’,’d’},q[]==="abc",r[]="abcde"; strcat(p,r);strcpy(p+strlen(q),q); prin
admin
2016-12-18
17
问题
有以下程序
#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、11
C、6
D、7
答案
C
解析
字符串连接函数stxcat(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/nfDp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
数据结构分为线性结构和非线性结构,线性表、栈和队列都属于【】。
【】(黑箱或白箱)测试方法完全不考虑程序的内部结构和内部特征。
已知函数的调用形式为fread(buf,size,count,fp),参数buf的含义是
下面判断正确的是
若变量已正确定义,有以下程序段i=0;doprintf("%d,",i);while(i++);printf("%d\n",i);其输出结果是
有以下程序段intj;floaty;charname[50];scanf("%2d%f%s",&j,&y,name);当执行上述程序段,从键盘上输入555667777abc后,y的值为
以下不属于对象的基本特点的是
以下选项中,当x为大于l的奇数时,值为0的表达式是
对下列二叉树:进行前序遍历的结果为______。
数据的逻辑结构有线性结构和______两大类。
随机试题
双向沟通
实验组、控制组前后测设计的基本模式是()
服用洋地黄药物期间应禁忌使用()
工程咨询单位由()办理资格认定工作。
学校社区工作包括哪些工作内容?( )
有人认为,任何一个机构都包括不同的职位等级或层级,每个人都隶属于其中一个层次。如果某人在原来级别岗位上干得出色,就会被提拔,而被提拔者得到重用后却碌碌无为,这会造成机构效率低下,人浮于事。以下哪项为真,最能质疑上述观点?
下列叙述中正确的是()。
Wheredoestheconversationmostprobablytakeplace?
Humour,whichoughttogiverisetoonlythemostlight-heartedandgayfeelings,canoftenstirupvehemenceandanimosity.Evi
Idon’tfeellikeswimmingintheseatoday,I’dratherlieonthe______.
最新回复
(
0
)