柠檬试题库
search
首页
计算机
公务员
驾照
关于
share
有以下程序 #include
#include
main() { int i; char a[]="How are you!"; for (i=0; a[i]; i++) if (a[i] == ' ') strcpy(a, &a[i+1]); printf("%s\n",a); } 程序的运行结果是
A.are you!
B.Howareyou!
C.areyou!
D.areyou!
热度🔥1,245
参考答案:A
解析:
【解析】复制字符串函数strcpy(str1,str2),将str2完整的(包括“\0”)复制到str1中,str1中原有的内容被覆盖。程序执行过程为:在a[i]不等于“\0”的情况下,判断当前元素是否为空格,若为空格将下一个元素以及之后的所有字符复制到a数组中。当i=3时,if条件成立,a中元素为“are you!\0”,之后的元素中在“\0”前没有空格出现,输出are you!,A选项正确。
复制题目向AI提问
content_copy
content_copy
扫码免费计算机二级刷题
2025年计算机等级考试题库
推荐
若有以下程序 #include main() { char a[20], b[ ]="The sky is blue."; int i; for (i=0; i表示回车符) Fig flower is red. 则输出结果是
若有以下程序 #include typedef struct stu { char name[10], gender; int score; } STU; void f(STU a, STUB) { b = a; printf( "%s,%c,%d,", b.name, b.gender, b.score ); } main() { STU a={"Zhao", 'm', 290}, b={"Qian", 'f', 350}; f(a,b); printf("%s,%c,%d\n", b.name, b.gender, b.score); } 则程序的输出结果是
以下对伪指令的解释错误的是( )。
下列存储管理方案中,允许动态扩充内存容量的方案是
标签
二级C语言
are
you
元素
str