Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/158.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我怎么睡C++;持续3秒钟,然后启动 你好我正在学习C++,我想知道在代码开始前3秒钟如何暂停我的代码。 因此,当用户点击回车键时,它将暂停三秒 #include <iostream> using namespace std; int main() { int x = 10; cout<<"BEGIN\n"; cin.get(); while( x < 11 ) { cout<<"123456789"; } } #包括 使用名称空间std; int main() { int x=10; cout_C++ - Fatal编程技术网

我怎么睡C++;持续3秒钟,然后启动 你好我正在学习C++,我想知道在代码开始前3秒钟如何暂停我的代码。 因此,当用户点击回车键时,它将暂停三秒 #include <iostream> using namespace std; int main() { int x = 10; cout<<"BEGIN\n"; cin.get(); while( x < 11 ) { cout<<"123456789"; } } #包括 使用名称空间std; int main() { int x=10; cout

我怎么睡C++;持续3秒钟,然后启动 你好我正在学习C++,我想知道在代码开始前3秒钟如何暂停我的代码。 因此,当用户点击回车键时,它将暂停三秒 #include <iostream> using namespace std; int main() { int x = 10; cout<<"BEGIN\n"; cin.get(); while( x < 11 ) { cout<<"123456789"; } } #包括 使用名称空间std; int main() { int x=10; cout,c++,C++,延迟和计时是一个平台问题,您需要为此使用特定于平台的API 在web上搜索您的平台API和“睡眠事件”字样。#包括睡眠(500)睡500milliseconds@cageman,谁说过Windows?有一个标准的睡眠函数:std::this_thread::sleep_for或std::this_thread::sleep_until。这就是为什么我没有把它作为答案,而是一个快速的评论。@chris:仅在C++11及更高版本中。早期版本不支持线程。@ThomasMatthews,是的,un幸运的

延迟和计时是一个平台问题,您需要为此使用特定于平台的API


在web上搜索您的平台API和“睡眠事件”字样。

#包括睡眠(500)睡500milliseconds@cageman,谁说过Windows?有一个标准的睡眠函数:
std::this_thread::sleep_for
std::this_thread::sleep_until
。这就是为什么我没有把它作为答案,而是一个快速的评论。@chris:仅在C++11及更高版本中。早期版本不支持线程。@ThomasMatthews,是的,un幸运的是,Boost仍然拥有它们。