Dear Unregistered,
Problem is that scanf() will read from standard input (most often keyboard) until it finds a newline character (the 'enter' key). When it finally finds the newline character, it doesn't take it with the rest of the data to be formatted !! Instead, it is left in the input stream !! When next scanf() in program is processed it will read that newline character left from former scanf() and put it in the first variable in the variable list. Exemple :
Code:
scanf ("%d", &a_number);
scanf ("%c", &a_character);
In this case, the newline charater by first scanf() in input buffer will be put in a_character by second scanf(). We can avoid this inconvenience by means of a space character in format string in second scanf(), right befor %c. Or we can just use a function, like getchar() that "eats" that newline character.
Code:
scanf ("%d", &a_number);
scanf (" %c", &a_character); /* space character before %c */
or ...
Code:
scanf ("%d", &a_number);
while (getchar() != '\n'); /* usually implemented this way */
scanf ("%c", &a_character);