#include #include #include #include #include #include int main(int argc, char *argv[]) { int i; struct stat statbuf1, statbuf2; // struct utimbuf timebuf; if (argc != 3) { printf("Usage: a.out file1 file2\n"); exit(1); } if (stat(argv[1], &statbuf1) == -1) { printf("File %s not there.\n", argv[1]); exit(2); } if (stat(argv[2], &statbuf2) == -1) { printf("File %s not there.\n", argv[2]); exit(2); } printf("last modified time for %s is %s\n", argv[1], ctime(&(statbuf1.st_mtime))); printf("last modified time for %s is %s\n", argv[2], ctime(&(statbuf2.st_mtime))); if (statbuf1.st_mtime < statbuf2.st_mtime) { printf("%s is modified later.\n", argv[2]); } else printf("%s is modified later.\n", argv[1]); }