我有一个列出 unix 时间戳的文件(文本文件),我想将它们转换为 time_t 并将其保存到另一个文件(二进制文件)中;
char timestamp[12];
timestamp[11] = '\0';
while (! feof(log)) {
time_t t;
/* 10 character for timestamp + 1 for newline */
fread(timestamp, sizeof(char), 11, log);
/* Black magic goes here */
/*save time_t into new log */
fwrite(&t,sizeof(time_t),1,newlog);
}