#include "stdafx.h"
#include <iostream>
#include <time.h>
using namespace std;
#define TIMESPAN 1
int _tmain(int argc, _TCHAR* argv[])
{
time_t first,second;
first=time(NULL);
second=time(NULL);
while(1){
second=time(NULL);
if(difftime(second,first)==TIMESPAN){
//每隔TIMESPAN秒,执行采样;
cout<<"aaa"<<endl;
first=time(NULL);
}
}
system("pause");
return 0;
}
C++ 实现每隔一段时间采样效果
最新推荐文章于 2024-04-23 04:33:05 发布