【问题标题】:can scanf be terminated on pressing some specific key other than enterscanf 是否可以在按 enter 以外的某个特定键时终止 【发布时间】:2010-02-10 08:55:03 【问题描述】: 我这里有个情况 我正在接受用户的输入 使用 scanf 我可以在用户按下 # 键后立即终止 scanf 请赐教 【问题讨论】: 标签: c scanf 【解决方案1】: 不,scanf()(或者更确切地说是标准输入,默认情况下)是面向行的,因此它需要读取整行。 查看 ncurses 或类似的库以获取“原始”按键输入。 【讨论】: