Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
(C Linux)strftime返回损坏的日期时间_C_Linux_Time - Fatal编程技术网

(C Linux)strftime返回损坏的日期时间

(C Linux)strftime返回损坏的日期时间,c,linux,time,C,Linux,Time,我正在使用以下代码: char dateModified[101]; setlocale(LC_TIME, "en_US.UTF-8"); //Get address for the file's modified time: struct timespec *timeP = &(filesList[i].mtime); //Translate the time to text strftime(dateModified, 100, "%b %e %Y %R", time

我正在使用以下代码:

char dateModified[101];
setlocale(LC_TIME, "en_US.UTF-8");
    //Get address for the file's modified time:
struct timespec *timeP = &(filesList[i].mtime);
    //Translate the time to text
strftime(dateModified, 100, "%b %e %Y %R", timeP);
    //Print time since 1970, address of the struct and formatted time
printf("%d %d \'%s\'\n", timeP->tv_sec, timeP, dateModified);
格式化和打印多个文件的上次修改时间。但是,即使时间戳是正确的,格式化的时间也总是不正确的。 有什么问题吗? 某些文件的输出:

TIMESTAMP  ADDRESS   FORMATTED TIME
1494268890 15343728 '?  0 1852401361 74573639:00'
1494268890 15344048 '?  0 1701605586 74573639:00'
1494268890 15344368 '?  0 1885498010 74573639:00'
1494268889 15344688 '?  0 1900 130561033:00'

(所有时间戳均指向2017年5月8日下午6:41(UTC))

注意:
timeP->tv_sec
timeP
都不是
printf
格式规范
%d
要求的
int
类型。是的,将tv_sec固定为长。至于timeP,我只是想看看地址,这一行不会停留在代码中请不要编辑您发布的代码,这将混淆任何以下评论<代码>%l不是有效的格式说明符。我认为“timespec”是错误的类型:size\t strftime(char*,size\t,const char*,const struct tm*);