首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include main() {char p[20]={’a’,’b’,’c’,’d’},q[]="abc",r[]="abcde"; strcat(p,r);strcpy(p+strlen(q),q);
有以下程序 #include main() {char p[20]={’a’,’b’,’c’,’d’},q[]="abc",r[]="abcde"; strcat(p,r);strcpy(p+strlen(q),q);
admin
2019-05-17
21
问题
有以下程序
#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/PHRp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
对于循环队列,下列叙述中正确的是()。【09年9月】
有以下程序voidfun(intX,inty,int*c,int*d){*c=x+y;*d=x-y;)main(){inta=4,b=3,c=0,d=0;fun(a,b,&c,&d);
有以下程序#include#definef(x)x*x*xmain(){inta=3,s,t;s=f(a+1);t=f((a+1));printf("%d,%d\n"
检查软件产品是否符合需求定义的过程称为
下面对对象概念描述正确的是
有以下程序#include#includevoidfun(int*p1,int*p2,int*s){s=(int*)calloc(1,sizeof(int));*s=*p1+*p2;free(s);}
有以下函数intfun(char*s){char*t=s;while(*t++);retum(t-s);}该函数的功能是
以下选项中不属于C语言标识符的是
下面选项中关于“文件指针”概念的叙述正确的是
以下说法正确的是()。
随机试题
感知电流是指能使人感觉到的最小电流,对于工频交流为()。
简述劳动说的意义及缺陷。
导致烧伤创面延迟愈合的因素
患者,女,32岁。主因月经淋漓不尽、皮肤出血点3月伴乏力半月入院。查体:双下肢皮肤见瘀点、瘀斑,巩膜无黄染,肝未扪及,脾轻度肿大。提示:骨穿细胞学分类“见巨核细胞45个,颗粒型巨核细胞40个,裸巨核细胞5个,血小板罕见”。该患者很可能的诊断是1.再生
患者男,62岁。5年来站立、咳嗽时反复出现左侧腹股沟肿块,呈梨形,平卧可消失,12小时前搬家具时肿块增大,有明显疼痛,平卧和手推均不能回纳,肛门停止排便排气。诊断为腹外疝入院治疗。该患者最合适的治疗措施是
室温过高时,人体会
混凝土试件的标准养护条件为()。
根据《税收征收管理法》的规定,下列各项中,属于税收强制执行措施的是()。
区分正常与异常心理的统计学标准认为()。
Drought,tsunami,violentcrime,financialmeltdown—theworldisfullofrisks.Thepoorareoftenmost【C1】______totheireffec
最新回复
(
0
)