下述语句中,在字符串s1和s2相等时显示“they are Equal”的是( )。

admin2013-02-23  20

问题 下述语句中,在字符串s1和s2相等时显示“they are Equal”的是(    )。

选项 A、if(*s1==*s2)
  puts(“they are Equal”);
B、if(!strcmp(s1,s2))
  puts(“they are Equal”);
C、if(s1==s2)   
puts(“they are Equal”);
D、if(strcmp(s1,s2))
  puts(“they are Equal”);

答案B

解析 字符串比较不能用“==”,要用strcmp(s1,s2)函数,字符串s1和s2相等时返回值为0,故!strcmp(s1,s2)==1,条件成立执行后面的语句,输出they are Equak
转载请注明原文地址:https://kaotiyun.com/show/VBJp777K
0

最新回复(0)