I'm still learning the basics of C right now and I wanted to build a simple 'enter y to loop the program' that I've seen in a lot of console programs and wrote the following code to test it out. When I do execute it however, it does work as intended once after which the program just exits. It would help me a lot if anyone told me what I'm doing wrong here :
int main()
{
char l;
do
{
printf("Loop successful.\n");
fflush(stdin); //I heard this has to be used because scanf keeps the enter key in buffer or something like that
scanf_s("%c", &l);
} while (l == 'y');
}
I also get a "Missing integer argument to 'scanf(_s)' that corresponds to conversion specifier '2'" warning and I don't seem to understand what I'm being warned against.