http://blog.csdn.net/tangweide/article/details/7063747
从论坛上转来的:
(—)使用_sleep()函数
#include <iostream>
using namespace std;
_sleep(5*1000);//延时5秒
(二)使用Delay(int time)函数
#include <ctime>
void Delay(int time)//time*1000为秒数
{
clock_t now = clock();
while( clock() - now < time );
}
Delay(5*1000); //延时5秒
在Linux下
#include <unistd.h>
sleep(5)//延迟5秒
如果你想延迟一秒以内
那么用
#include <ctime>
void Delay(int time)//time*1000为秒数
{
clock_t now = clock();
while( clock() - now < time );
}