C++ Sleep() 函数

Sleep 函数在windows 系统下 需要引入头文件 #include<windows.h>

作用是让当前程序等待一段时间,Sleep 函数的单位是毫秒

下面写一个耗时操作:

#include <iostream>
using namespace std;
#include<windows.h>
int main()
{	
	 DWORD start_time = GetTickCount();
	 Sleep(3000);
	 DWORD end_time = GetTickCount();
	 cout<<"Time=" << end_time - start_time<< endl;

}

注意在linux 系统下是sleep()

猜你喜欢

转载自blog.csdn.net/qq_33210042/article/details/131415268