#include "stdafx.h"
#include<time.h>
#include<Windows.h>
#include<iostream>
using namespace std;
int main()
{
cout << "秒精确" << endl;
time_t start, end;
start = time(NULL);
Sleep(2000);
end = time(NULL);
printf("time: %f\n", difftime(end, start));
//Sleep的模拟只是一个非常近似的模拟,会有一点误差
cout << "毫秒精确" << endl;
DWORD ds, de;
ds = GetTickCount();
#include<time.h>
#include<Windows.h>
#include<iostream>
using namespace std;
int main()
{
cout << "秒精确" << endl;
time_t start, end;
start = time(NULL);
Sleep(2000);
end = time(NULL);
printf("time: %f\n", difftime(end, start));
//Sleep的模拟只是一个非常近似的模拟,会有一点误差
cout << "毫秒精确" << endl;
DWORD ds, de;
ds = GetTickCount();