Issues with using scanf() to scan characters in loops in C
I've been a member of the question and answer site Stack Overflow for nearly a year now and there is one question that's always asked by beginners in C language regarding scanning characters in a loop. Generally they would have a program like this: #include "stdlio.h" int main(void) { char again = 'y'; //declaration and initialisation of a `char` variable //declarations of other variables... //program.... //THE LOOP while (again == 'y') { //looping statement..... printf("want again? y/n : "); //THE PROBLEM scanf("%c", &again); //scanning the character } //rest of the program.... return 0; } and the question is why does the loop run only once even though they have entered input as `y` when prompted the message `want again?` while running the executable file. If you've ...