I am trying to set up a loop where user can continue entering string. Not sure where i am going wrong (I am new to C programming)
this is the code i have written:
#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);
}
This is the output i am getting:
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
Thanks in advance.