如何正确比较字符串?
我试图让一个程序让用户输入一个单词或字符,存储它,然后打印它直到用户再次键入它,退出程序。我的代码看起来像这样:
#include <stdio.h>int main(){
char input[40];
char check[40];
int i=0;
printf("Hello!\nPlease enter a word or character:\n");
gets(input);
printf("I will now repeat this until you type it back to me.\n");
while (check != input)
{
printf("%s\n", input);
gets(check);
}
printf("Good bye!");
return 0;}问题是我不断打印输入字符串,即使用户输入(检查)与原始(输入)匹配。我比较错误吗?
繁星coding
慕容森