/* 标准I/O 文件I/O */
1 #include <dirent.h>
2 #include <stdio.h>
3 #include <sys/stat.h>
4 #include <time.h>
5
6 int main()
7 {
8 DIR *dir;
9 struct dirent *dent;
10 struct stat buf;
11 dir = opendir(".");
12 if(dir)
13 {
14 while((dent = readdir(dir))!=NULL)
15 {
16 stat(dent->d_name,&buf);
17 struct tm *t=localtime(&buf.st_ctime);
18 printf("create time:%04d-%02d-%02d %02d:%02d:%02d ",t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
19 printf("name:%-16s size:%d\n",dent->d_name,(int)buf.st_size);
20 }
21 }
22
23 }