#include<stdio.h>
int main(void)
{
char name[40];
scanf("%s",name);
if(name == "yes")
{
printf("%s",name);
}
return 0
}
最佳答案
您需要使用strcmp
进行字符串比较。
替换
if(name == "yes")
与
if(strcmp(name,"yes") == 0)
<小时/>
strcmp
返回
-
0 if both strings are identical (equal)
-
Negative value if the ASCII value of first unmatched character is less than second.
-
Positive value if the ASCII value of first unmatched character is greater than second.
关于C语言关于输入输出的printf函数的类型完全相同,但是为什么我看不到输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53103571/