home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / comms_networking / users / Utilities / c / rectime < prev   
Encoding:
Text File  |  1998-01-01  |  592 b   |  40 lines

  1. /* rectime.c
  2.  * Records time
  3.  * (c) Chris Rutter 1997
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <time.h>
  10.  
  11. int main (int argc, char *argv[])
  12. {
  13.     if (argc!=3)
  14.     {
  15.         fprintf (stderr, "Usage: rectime <file> <message>\n");
  16.         exit (1);
  17.     }
  18.  
  19.     {
  20.         FILE *fp;
  21.         time_t t=0;
  22.         struct tm *tm;
  23.         char tb[256];
  24.     
  25.         fp=fopen(argv[1],"a+");
  26.         if (!fp)
  27.         {
  28.             fprintf (stderr, "Failed to open %s.\n", argv[1]);
  29.             exit(1);
  30.         }
  31.     
  32.         t=time(&t);
  33.         tm=localtime(&t);
  34.         strftime (tb, 256, "%d %b %H:%M:%S", tm);
  35.     
  36.         fprintf (fp, "%s %s\n", tb, argv[2]);
  37.         fclose (fp);
  38.     }
  39. }
  40.