📜  如何阻止scanf在中添加新行 - C编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:35.734000             🧑  作者: Mango

代码示例1
For a simple solution, you could add a space before the format specifier when you use scanf(), for example: scanf(" %c", &ch); The leading space tells scanf() to skip any whitespace characters (including newline) before reading the next character, resulting in the same behavior as with the other format specifiers.