标准库中无sleep函数,但在某些编译系统中是有的,在有些系统库中也有,要根据环境而定。
如:
linux中有,unsigned int sleep(unsigned intseconds),传入挂起时间,成功返回0,不成功则返回余下的秒数(这里sleep(1),暂停1s)。
windows系统中有Sleep函数(注意大写),void Sleep(DWORD dwMilliseconds);提供挂起的毫秒数,并且需包含windows.h。
<span style="font-size:18px;">#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
Sleep(3000);//暂停3秒 S要大写
return 0;
}
</span>
原文:https://blog.youkuaiyun.com/qq_28796345/article/details/51290391
本文详细介绍了在不同操作系统中如何使用sleep函数实现程序暂停。在Linux中,可使用unsigned int sleep(unsigned int seconds)函数,传入挂起时间,成功返回0;在Windows系统中,则需调用void Sleep(DWORD dwMilliseconds),并包含windows.h头文件。
3万+

被折叠的 条评论
为什么被折叠?



