2
當我運行程序並回答「是」時,它告訴我我錯了。有沒有人知道執行這種類型的程序的方法?這個程序中的strcmp有什麼問題?
#include <string.h>
#include <stdio.h>
int strcmp(const char *str1,const char *str2);
// I am trying to make a program that asks the user to input an answer
int main()
{
char answer[20];
printf("Can birds fly?\n");
scanf("%s", &answer[20]);
if(strcmp(answer, "yes") == 0)
{
printf("You are right");
}else
{
printf("You are worng");
}
return 0;
}
謝謝,它的工作! – user1867232
@ user1867232既然它有效,考慮接受作爲你問題的答案 – dreamcrash