在C++中,并没有直接的pause
函数。如果你想要在程序中暂停一段时间,可以使用std::this_thread::sleep_for
函数来实现。
示例代码如下:
#include <chrono>
#include <thread>
int main() {
// 暂停1秒钟
std::this_thread::sleep_for(std::chrono::seconds(1));
return 0;
}
上述代码将会暂停程序的执行1秒钟。你也可以使用std::chrono::milliseconds
来暂停指定的毫秒数,或者使用std::chrono::minutes
、std::chrono::hours
等来暂停更长的时间。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: c++中cast的作用是什么