这将显示多少秒:
#include <iostream>
#include <time.h>
using namespace std;
int main(void)
{
int times,timed;
times=time(NULL);
//CODE HERE
timed=time(NULL);
times=timed-times;
cout << "time from start to end" << times;
}
这将显示有多少滴答声:
#include <iostream>
#include <time.h>
using namespace std;
int main(void)
{
int times,timed;
times=clock();
//CODE HERE
timed=clock();
times=timed-times;
cout << "ticks from start to end" << times;
}
我如何获得毫秒?
原文由 SomeUser 发布,翻译遵循 CC BY-SA 4.0 许可协议
请参阅 Stack Overflow 上的问题“ 将 2 次之间的差异转换为毫秒”。
或者使用这个: