我怎么睡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
延迟和计时是一个平台问题,您需要为此使用特定于平台的API我怎么睡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幸运的
在web上搜索您的平台API和“睡眠事件”字样。#包括睡眠(500)睡500milliseconds@cageman,谁说过Windows?有一个标准的睡眠函数:
std::this_thread::sleep_for
或std::this_thread::sleep_until
。这就是为什么我没有把它作为答案,而是一个快速的评论。@chris:仅在C++11及更高版本中。早期版本不支持线程。@ThomasMatthews,是的,un幸运的是,Boost仍然拥有它们。