ユーザーが文字列を入力し続けることができるループを設定しようとしています。どこが間違っているのかわかりません(Cプログラミングは初めてです)
これは私が書いたコードです:
#include <stdio.h>
void main() {
int repeat;
char str[30];
do
{
printf("Enter a string:");
fgets(str, 30, stdin);
printf("Do you want to continue\n");
fflush(stdin);
scanf_s("%d", &repeat);
} while (repeat==1);
}
これは私が得ている出力です:
Enter a string:hello
Do you want to continue
1
Enter a string:Do you want to continue
1
Enter a string:Do you want to continue
前もって感謝します。