求教! error C3861: “getticktime”: 找不到标识符 error C3861: “getticktime”: 找不到标识符

2025-01-17 05:38:39
推荐回答(3个)
回答1:

有getticktime这个函数么?
windows.h里倒是有GetTickCount()函数,但没有getticktime()函数,不过是用来获取从开机到该API执行时系统所过的时间,单位为毫秒
是不是写错了?
同时windows的API一般都是用匈牙利命名法的,所以全小写肯定有问题

回答2:

没头文件,我也不知道头文件是哪个,不过你可以试下用这个函数取时间time(NULL)
#include
long oldTime = time(NULL); //执行一次取得时当前系统时间
for(int i = 0; i<10000; ++i)
{}
long newTime = time(NULL);

回答3:

#include
#include
using namespace std;

int main()
{
double start=GetTickCount(),end(0);
//ToDo:process code
int counter_1,counter_2,counter_3;
for (counter_1 = 0;counter_1 < 1000;counter_1++)
for (counter_2 = 0;counter_2 < 1000;counter_2++)
for (counter_3 = 0;counter_3 < 1000;counter_3++)
;
end=GetTickCount();
double result=end-start;
printf("result=%lf\n",result);
return 0;
}