Let's say you input 2 when you're reading for num. The actual input stream will be 2
(
is the newline character). 2 goes into the num, and there remains
, which goes into ch. To avoid this, add a whitespace in format specifier.
scanf(" %c", &ch);
This will ignore any whitespaces, newlines or tabs.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…