#include void main() { char a[20], b[2

#include void main() { char a[20], b[2,第1张

#include void main() { char a[20], b[2

问题:

[单选] #include void main()

{

char a[20], b[20], c[20];

scanf("%s%s", a, b);

gets(c);

printf("%s%s%s", a, b, c);

}

程序运行时从第一行开始输入thisisacat!<回车>,则输出结果是(  )。


thisisacat!

thisisa

thisisacat!

thisisacat!


A . thisisacat!

B . thisisa

C . thisisacat!

D . thisisacat!

正确答案:

C

参考解析:

考察scanf和gets输入字符串的区别,scanf语句接收字符时遇到空格就作为一个字符串的结束,所以a数组中为this,b数组中为is,但是getchar函数见到回车才认为结束所以c数组为acat!。所以打印结果如选项C。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5629147.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存