【问题标题】:Alternative for getch() c++getch() c++ 的替代方案
【发布时间】:2018-02-13 07:33:37
【问题描述】:

有人可以给我一个很好的替代 c++ 中的 getch() 函数吗?我想从键盘上读取符号,getch 在 ideone 和代码块中的在线判断上出错,一切顺利。

【问题讨论】:

标签: c++


【解决方案1】:

下面试试

int ch = std::cin.get();

【讨论】:

  • std::cin.get() 执行缓冲输入,而 getch() 执行无缓冲输入。在我的系统上,这实际上意味着我需要按两次Enterstd::cin.get()
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-06
  • 2011-08-24
相关资源
最近更新 更多