如何在C中从struct tm转换为long int?

Var*_*ári 4 c linux

这是一个简单的问题......有没有办法将a转换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);
Run Code Online (Sandbox Code Playgroud)

小智 11

您可以使用该mktime()函数将a转换struct tm为a time_t,这是一个整数值.