【发布时间】:2019-04-17 18:41:27
【问题描述】:
当你发出这个命令时:
find ok/ -exec ls -l -d {} \;
终端显示:
drwxrwxrwx 2 alexia alexia 4096 8 oct. 15 22:31 ok/
我尝试用自己的 find 命令对 stat.h 做同样的事情:
[...] //Other file information
struct stat fileStat;
stat(path,&fileStat)
char buffer[20];
struct tm *time
time = localtime(&(fileStat.st_mtime));
strftime(buffer, 20, "%b %e %Y", time);
printf("%s", buffer);
它会显示:
[...]
8 Oct 15 22:31 ok/
月份格式不好,不知道怎么弄好。
干杯
【问题讨论】:
-
你设置了语言环境吗?默认情况下,它适用于 C 语言环境。也许
setlocale(LC_TIME, “”);?否则,您可以将点添加到格式字符串中,但这不能解决缩写的情况。 -
有效!谢谢!
-
@user3592221:当你收到一个有用的问题答案时,你应该accept这个答案,这样其他人就知道它不再需要回答了。