C - error message outputs for each character user enters in single line?

So I'm writing a part of a program in c where I need the user to enter a character (A, B, or C). If they enter it in lowercase, enter more than one character, or if they enter a space or a letter outside of the above, it should output "Answer is invalid. Please re-enter." until they enter a valid... show more So I'm writing a part of a program in c where I need the user to enter a character (A, B, or C). If they enter it in lowercase, enter more than one character, or if they enter a space or a letter outside of the above, it should output "Answer is invalid. Please re-enter." until they enter a valid answer.

I've ran into a problem where it outputs that error message for EACH character they use. So say if they entered "asdas" it would output the error message five times. Is there a way to make sure the error message only gets outputted one time?
Update: code: char getAnswer(){ char usersAnswer; while(1){ printf("Enter an answer (A, B, C): \n"); scanf("%c", &usersAnswer); if(answerisValid(usersAnswer)){ return usersAnswer; return 0; }else{ printf("Answer is... show more code:
char getAnswer(){
char usersAnswer;
while(1){
printf("Enter an answer (A, B, C): \n");
scanf("%c", &usersAnswer);
if(answerisValid(usersAnswer)){
return usersAnswer;
return 0;
}else{
printf("Answer is invalid. Please re-enter. \n");
}
}
}
2 answers 2