【发布时间】:2019-04-08 21:19:11
【问题描述】:
假设我们有
int n;
sscanf(" 42", "%2d", &n);
n 应该是 4(“%2d”占的空格)还是 42(忽略空格,使 scanf 读取 3 个字符)?
ideone implementation 读取 3 个字符
【问题讨论】:
-
来自 MacOS 上的手册页:“在转换开始之前,大多数转换都会跳过空白;此空白不计入字段宽度。”
标签: c language-lawyer standards