when i input “yy” scanf() uses the second y automatically and doesn’t wait for another char input.
`while(1) {
char response;
printf("Start new blackjack game? y/n: ");
scanf(" %1c", &response);
if(response == 'y') {
printf("game started!n");
} else if(response == 'n') {
break;
} else {
continue;
}
}`
I tried to make scanf() take in one character as a yes or no input to start a blackjack game but it always uses old, unused characters that were inputed, and it only works when one character is inputed.
New contributor
Insert0Name0Here is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.