有以下程序: #include<stdio.h> main() { char c[6]; int i=0; for(j<6;c[i]=getchar(),i++);

admin2010-09-05  17

问题 有以下程序:        #include<stdio.h>        main() {         char c[6];         int i=0;         for(j<6;c=getchar(),i++);         for(i=0,i<6;i++)putchar(c);         printf("\n");        }        如果从键盘上输入:        ab<回车>        c<回车>        def<回车>        则输出结果为______。

选项 A、a    b    c    d    e    f
B、a    b    c    d
C、ab    c    d
D、abcdef

答案C

解析 getchar():此函数的作用是从终端(或系统隐含指定的输入设备)输入—个字符。   2.putchar()此函数的作用是向终端输出—个字符,也可以输出控制字符。本题在输入字符时,ab和c后面的回车符分别赋给了c[2]和c[4],所以,正确答案为C。
转载请注明原文地址:https://kaotiyun.com/show/JdWp777K
0

最新回复(0)