这是一个简单的问题...有没有办法将struct tm ct;
转换为长整数?我的代码如下所示:
struct tm ct;
scanf("%d", &ct.tm_sec);
scanf("%d", &ct.tm_min);
scanf("%d", &ct.tm_hour);
scanf("%d", &ct.tm_mday);
scanf("%d", &ct.tm_mon);
scanf("%d", &ct.tm_year);
您可以使用mktime()
函数将struct tm
转换为整数值的time_t
。
你想要
得到一个time_t,它表示自 1/1/1970 00:00:00 以来的秒数
使用 mktime():
time_t mktime ( struct tm * timeptr );
http://www.cplusplus.com/reference/clibrary/ctime/mktime/