以下程序: #include<stdio.h> main() { char str[10]; scanf(’’%s’’,&str); printf(’’%s\n’’,str);} 运行上面的程序,输入字符串

admin2020-11-27  22

问题 以下程序:
    #include<stdio.h>
    main()
    {  char str[10];
    scanf(’’%s’’,&str);
    printf(’’%s\n’’,str);}
    运行上面的程序,输入字符串“how are you”,则程序的执行结果是(    )。

选项 A、how
B、how are you
C、h
D、howareyou

答案A

解析 当从键盘输入“how are you”时,由于scanf输入函数的特点是遇到空格时结束读入字符,因此,该程序只将how这3个字符送到了字符数组str中,并在其后自动加上结束符“\0”。
转载请注明原文地址:https://kaotiyun.com/show/he3p777K
0

最新回复(0)