关于 scanf 函数 % c 之前 与 之后 使用 空格 的 问题
你 看 c 标准 里 对 scanf format 的 说明 Whitespace character : the function will read and ignore any whitespace characters encountered before the next non - whitespace character ( whitespace characters include spaces , newline and tab characters - - see isspace ) . A single whitespace in the format string validates any quantity of whitespace characters extracted from the stream ( including none ) . 如果 你 是 " % c " , 读完 所有 的 字符 后 ， 还 需要 匹配 一 个 " " , 你 输入 任何 空白 字符 或 非 空白 字符 都 可以 完成 匹配 . 但 必须 有 这么 一 个 字符 。 如果 是 " % c " , 第一 个 " " 在 碰到 你 输入 的 a 时 就 完成 匹配 了 。 ( 参见 标准 中 最后 那个 including none )
