当先前定义的时间结束时,如何取消输入

How can I cancel an inputting when a previously defined time is over

我是 C++ 新手。我想通过代码块用这种语言创建这样一个程序,我们将被告知在特定时间内输入特定值。如果我们在特定时间内输入一个值,它会相应地工作,但如果我们延迟,程序就会结束。 帮助我,如果可以的话请添加代码...

它实际上是 operating system specific, since the C++11 (or C++14 or C++17) standard don't offer any such facilities (the only standardized way of getting input being C++ streams such as std::istream 或 C stdio 文件 à la FILE*)。您可能需要一些外部库。

在Linux或POSIX系统上,考虑(对于terminal interface) some library like ncurses. Perhaps a multiplexing system call, à la poll(2),应该有用(对于超时)。

也许你想要 GUI interface. Then look into Qt (or some other widget toolkit).