且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

怪异的行为scanf函数读取时数和新行

更新时间:2023-10-30 19:00:16

scanf函数格式字符串中的空格字符会导致 scanf函数至非空白字符发生消耗任何(和所有)的空白。

A whitespace character in your scanf format string will cause scanf to consume any (and all) white space till a non-whitespace char occurs.

这似乎是标准的 scanf函数行为,而不是仅限于海湾合作委员会。

This seems to be standard scanf behaviour and is not limited to gcc.