所以,我应该打印目录,修改和创建的访问日期,但它们似乎都是相同的日期。这是我的代码:
struct* tm date;
struct stat fileStat;
if(options[0] == 1 && options[1] == 0 && options[2] == 0 && options[3] == 0){
date = localtime(&(fileStat.st_mtime));
printf("M%02i/%d/%i-%02d:%02d", date->tm_mon,date->tm_mday, (date->tm_year + 1900)%100, date->tm_hour,date->tm_min);
date = NULL;
} else if(options[0] == 1 && options[1] == 1 && options[2] == 0 && options[3] == 0){
date = localtime(&(fileStat.st_atime));
printf("A%02i/%d/%i-%02d:%02d", date->tm_mon,date->tm_mday, (date->tm_year + 1900)%100, date->tm_hour,date->tm_min);
date = NULL;
} else if(options[0] == 1 && options[1] == 0 && options[2] == 1 && options[3] == 0){
date = localtime(&(fileStat.st_ctime));
printf("C%02i/%d/%i-%02d:%02d", date->tm_mon,date->tm_mday, (date->tm_year + 1900)%100, date->tm_hour,date->tm_min);
}
选项内容只是选择我要打印的那个。真的很感激一些帮助!感谢