Sleep()函数
功能: 执行挂起一段时间,也就是等待一段时间在继续执行
用法:Sleep(时间)
头文件: Windows下为--> windows.h
Linux 下为 --> unistd.h
注意:(1)Sleep需要区分大小写的
(2)括号里的时间,在windows下是以毫秒为单位,Linux是以秒为单位
//实现Windows下的倒计时
#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
int count = 5;
while (count)
{
printf("%d\r", count);
fflush(stdout);//刷新缓冲区
--count;
Sleep(1000);//毫秒为单位
}
}