若有以下程序 #include main() { char a[20], b[ ]="The sky is blue."; int i; for (i=0; i

admin2015-07-31  20

问题 若有以下程序
#include
main()
{  char  a[20], b[ ]="The sky is blue.";  int i;
for (i=0; i<10; i++)  scanf("%c", &a);
a=’\0’;
gets(B);
printf("%s%s\n", a,b);
}
执行时若输入:
Fig flower is red. <回车>
则输出结果是

选项 A、Fig flower is red.is blue.
B、Fig flower is red.
C、Fig floweris red.
D、Fig floweris

答案B

解析 本题考查字符数组的赋值以及字符串的处理函数,本题中输入字符串Fig flower is red时,首先是将前10个字符赋值给字符数组a,然后执行gets(b)后,将后续字符存放到b中,当输出时,首先输出字符数组a,然后输出字符串b,所以结果为B选项.
转载请注明原文地址:https://kaotiyun.com/show/aIDp777K
0

最新回复(0)