首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include<string.h> main() {char p[20]={’a’,’b’,’c’,’d’},q[ ]="abc",r[ ]="abcde"; strcat(p,r);strcpy(p+strlen(q),q); printf
有以下程序 #include<string.h> main() {char p[20]={’a’,’b’,’c’,’d’},q[ ]="abc",r[ ]="abcde"; strcat(p,r);strcpy(p+strlen(q),q); printf
admin
2019-12-17
11
问题
有以下程序
#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
解析
字符串连接函数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/Y2Cp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序#include<stdio.h>main(){inti,j,m=1;for(i=1;i<3;i++){for(j=3j>0;j--){if(i*j>3)break;m*=i*j;}}printf("m=%d\n",m);}
已知大写字母A的ASCII码是65,小写字母a的ASCII码是97。以下不能将变量c中的大写字母转换为对应小写字母的语句是
若要求从键盘读入含有空格字符的字符串,应使用函数
设有如下关系表。则下列操作中正确的是
以F函数按每行8个输出数组中的数据:voidfun(int*w,intn){inti;for(i=0:i<n;i++){______________printf("%d",w[i]);}printf("\n");}下划线处应填入的语句
若x和y代表整型数,以下表达式中不能正确表示数学关系|x-y|<10的是
在E-R图中,用来表示实体联系的图形是
读取二进制文件的函数调用形式为:fread(buffer,size,count,fp);其中buffer代表的是
数据流图用于抽象描述一个软件的逻辑模型,数据流图由一些特定的图符构成。下列图符名标识的图符不属于数据流图合法图符的是()。
在结构化方法中,用数据流程图(DFD)作为描述工具的软件开发阶段是()。
随机试题
以下有关出版物的说法,正确的是()。
继《黄帝内经》之后,现存最早的针灸学专著是
女性,26岁,因突发头昏、心慌、面色苍白加重2h入院。查体神志清楚,P120次/分,血压70/50mmHg,上腹部压痛、反跳痛。B超:腹腔积液,脾脏增大并不均质回声;腹腔穿刺抽出不凝血。9天前患者不慎自4米高处跌落,左侧身体先落地,感左侧腹疼痛,休息2天后
影响地表水水质的最主要因素是
2005年1月,为加快旧城改造进程,A省人民代表大会及其常务委员会制定了《A省旧城改造实施条例》,A省政府也制定了《A省旧城改造实施管理办法》。在此背景下,B市作为国务院确定的较大的市,也制定了相应的配套政策,并切实加大了旧城改造力度。2005年8月,C房
图示梁的最大剪力是()。
东方路桥公司中标承包了某高速公路工程后,组成了以公司副总经理为项目经理的项目经理部,下设技术部、材料部、合同部、财务部等。技术部在对收集的施工技术资料、施工定额及概预算资料、施工组织管理工作的有关政策规定、环境保护规定、公司对该工程施工的有关规定进行分析
关于现金使用范围,下列各项中,表述正确的有()。
阿甘正传:电影
おいしゃさんが薬をのむときのちゅういについてせつめいしました。ちゅうい
最新回复
(
0
)