将代码过程中比较重要的一些代码片段记录起来,如下的代码内容是关于C语言基础:mktime用法演示,输出时间差的代码。
#include <stdio.h>
#include <time.h>
int main(void)
{
time_t seconds;
struct tm time_fields;
time_fields.tm_mday = 4;
time_fields.tm_mon = 7;
time_fields.tm_year = 94;
time_fields.tm_hour = 0;
time_fields.tm_min = 0;
time_fields.tm_sec = 0;
seconds = mktime(&time_fields);
printf(“The number of seconds between 7-4-94 and 1-1-70 is %ldn”,
seconds);
return 1;
}
输出结果:GCC编译
The number of seconds between 7-4-94 and 1-1-70 is 775929600