【问题标题】:performing an operation if user doesn't give input in c++ [duplicate]如果用户没有在 C++ 中输入,则执行操作 [重复]
【发布时间】:2016-06-18 10:06:03
【问题描述】:

如果用户在c++中的某个时间间隔内没有输入,我有什么方法可以执行特定的操作吗?

【问题讨论】:

  • fread 和 alarm?
  • 大多数平台还允许您将标准输入设为非阻塞,并为您提供一个轮询框架(select、epoll、...),您可以在超时时驱动。

标签: c++


【解决方案1】:

不是严格的 ISO C++,因为基于 <iostream> 的功能是同步的。

除非使用某些特定于平台的 API...

也许这个How to make reading from `std::cin` timeout after a particular amount of time 可以提供帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-20
    • 2021-12-20
    • 1970-01-01
    • 2016-03-24
    • 1970-01-01
    • 1970-01-01
    • 2011-02-26
    • 1970-01-01
    相关资源
    最近更新 更多