如何正確比較字符串?我試圖讓一個(gè)程序讓用戶輸入一個(gè)單詞或字符,存儲(chǔ)它,然后打印它直到用戶再次鍵入它,退出程序。我的代碼看起來(lái)像這樣:#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;}問(wèn)題是我不斷打印輸入字符串,即使用戶輸入(檢查)與原始(輸入)匹配。我比較錯(cuò)誤嗎?
如何正確比較字符串?
叮當(dāng)貓咪
2019-05-23 11:06:22