The %c conversion reads the next single character from the input, regardless of what it is. In this case, you previously read the number with %d . You had to press enter to read this number, but you did nothing to read a new line from the input stream. Therefore, when you perform the conversion of %c , it reads this new line from the input stream (without waiting for you to actually enter something, since there is already entered waiting for reading).
When you use %s , it skips any leading white space to get a character other than white. It treats the new line as white space, so it implicitly skips this pending new line. Since there is (presumably) nothing waiting to be read, he continues to wait until you enter something, as you think.
If you want to use %c for conversion, you may be preceded by a space in the format string, which also skips any empty space in the stream.
source share