#include
int main()
{
char str[100];
scanf("%[^\n]%*c",str);//这里我输入了hello world
if(str=="hello world"){
printf("hello world");
}//可是它并没输出hello world
return 0;
}
字符串不能等号判断,使用strcmp函数
#include <stdio.h>
#include<string.h>
int main()
{
char str[100];
scanf("%[^\n]%*c",str);//这里我输入了hello world
if(strcmp(str,"hello world") == 0){
printf("hello world");
}//可是它并没输出hello world
return 0;
}
if(str=="hello world"){错误方法,改为
if(strcmp(str,"hello world") == 0)
另外要增加 #include <string.h>