C++获取时间并命名为文件名

#include <time.h>

char pStrPath1[20];
time_t currTime;
struct tm *mt;
Mat saveImg1;

currTime = time(NULL);
mt = localtime(&currTime);
/*根据日期生成文件名*/
sprintf(pStrPath1, "D:\\images\\face\\yr0905\\%d%02d%02d%02d%02d%02d.jpg", mt->tm_year + 1900, mt->tm_mon + 1, mt->tm_mday, mt->tm_hour, mt->tm_min, mt->tm_sec);
imwrite(pStrPath1, saveImg1);

 

posted @ 2018-09-06 17:16  西北逍遥  阅读(2865)  评论(0编辑  收藏  举报