You have else (anwser != 'y')
. It should be else if (anwser != 'y')
, or better yet just else
. The prompt Would you like to run it again? Y/N
will also be printed twice because of how your loop is structured. You have quite a few mistakes, but here's some advice on your loop.
You can use your anwser
variable in your while
condition. answerint
is unnecessary. Also, when you type a character and press enter, scanf
(with %c
) will extract the character but leave the newline in the buffer. That means the next call to scanf
will return a newline, which will make it appear as if your program is skipping your input statements. To fix this, add a space before the %c
in your call:
scanf(" %c", &charIn);
Your logic was also a bit out of place. Look at how this example is structured.
printf("Enter a character to be examined: ");
scanf(" %c", &charIn);
theQnA(charIn);
printf("Would you like to run it again? y/n\n");
scanf(" %c", &anwser);
while (anwser == 'y')
{
printf("Enter in another character buddy: ");
scanf(" %c", &charIn);
theQnA(charIn);
printf("Would you like to run it again? y/n\n");
scanf(" %c", &anwser);
}