C: scanf input single character and validation
问题 I've encountered a problem when validating a single-char scanf input in C and I cannot find an existing solution that works... The scenario is: a method is taking a single letter 'char' type input and then validating this input, if the criteria is not met, then pops an error message and re-enter, otherwise return this character value. my code is: char GetStuff(void) { char c; scanf("%c", &c); while(c != 'A' || c != 'P') { printf("invalid input, enter again (A for AM or P for PM): "); scanf ("