对下述程序的判断中,正确的是( )。 #include<stdio.h> void main() {char *P,s[256]; p=s; while(strcmp(s,"the end")) {printf("

admin2013-06-11  41

问题 对下述程序的判断中,正确的是(    )。    #include<stdio.h>    void main()    {char *P,s[256];    p=s;    while(strcmp(s,"the end"))    {printf("Input the string:");    gets(s);    while(*P)    putchar(*p++);}}

选项 A、此程序循环接收字符串并输出,直到接收到字符串“the end”为止
B、此程序循环接收字符串,接收到字符串“the end”则输出,否则程序终止
C、此程序循环接收字符串并输出,直到接收字符串“the end”为止,但因为代码有错误,程序不能正常工作
D、此程序循环接收字符串并将其连接在一起,直到接收字符串“the end”为止,输出连接在一起的字符串

答案A

解析 strcmp(str1,str2)是比较字符串str1和sir2,当两字符串相等时,返回值为0,不相等时返回值为非0;所以此段程序的功能是在未接收到字符串“the end”时,读入字符并输出。
转载请注明原文地址:https://jikaoti.com/ti/dtn0FFFM
0

最新回复(0)