home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / c / cuj9301.zip / 1101118B < prev    next >
Text File  |  1992-11-03  |  587b  |  31 lines

  1. /* ftime.c: Compare file time stamps */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <sys/stat.h>
  6. #include <time.h>
  7.  
  8. main()
  9. {
  10.     struct stat fs1, fs2;
  11.         
  12.     if (stat("time1.c",&fs1) == 0 && 
  13.         stat("time2.c",&fs2) == 0)
  14.     {
  15.         double interval =
  16.           difftime(fs2.st_mtime,fs1.st_mtime);
  17.  
  18.         printf("time1.c %s newer than time2.c\n",
  19.           (interval < 0.0) ? "is" : "is not");
  20.         return EXIT_SUCCESS;
  21.     }
  22.     else
  23.         return EXIT_FAILURE;
  24. }
  25.  
  26. /* Output
  27. time1.c is not newer than time2.c
  28. */
  29.  
  30. /* End of File */
  31.