#include <stdio.h>
int main ()
{
char loop='y';
while(loop != 'n') {
printf("loop? ");
scanf("%c", &loop);
if(loop != 'y') {
loop='n';
}
}
return 0;
}
If I type in 'y' he restart the while-loop but ignores the scanf the second time and end the loop after that. Can anyone help?
Make sure the scanf
discards the newline. Change it to:
scanf(" %c", &loop);
^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With