#include <stdio.h>
#include <time.h>
#include <iostream>
#include <fstream>
void GetCurrentTime(std::string &cur)
{
struct tm *ptm;
long ts;
char curtim[100];
ts = time(NULL);
ptm = localtime(&ts);
sprintf(curtim,"%d-%d-%d-%d-%d-%d",ptm->tm_year+1900,
ptm->tm_mon + 1,
ptm->tm_mday,
ptm->tm_hour,
ptm->tm_min,
ptm->tm_sec);
cur = curtim;
}
int main()
{
for(uint8_t i=0; i<5; i++)
{
char tmp[5];
std::string cur;
sprintf(tmp,"-%d",i);
GetCurrentTime(cur);
cur.append(tmp);
cur.append(".jpg");
std::cout << cur << std::endl;
}
}
linux获取系统时间
最新推荐文章于 2024-10-13 15:00:00 发布