home *** CD-ROM | disk | FTP | other *** search
- /* rectime.c
- * Records time
- * (c) Chris Rutter 1997
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
-
- int main (int argc, char *argv[])
- {
- if (argc!=3)
- {
- fprintf (stderr, "Usage: rectime <file> <message>\n");
- exit (1);
- }
-
- {
- FILE *fp;
- time_t t=0;
- struct tm *tm;
- char tb[256];
-
- fp=fopen(argv[1],"a+");
- if (!fp)
- {
- fprintf (stderr, "Failed to open %s.\n", argv[1]);
- exit(1);
- }
-
- t=time(&t);
- tm=localtime(&t);
- strftime (tb, 256, "%d %b %H:%M:%S", tm);
-
- fprintf (fp, "%s %s\n", tb, argv[2]);
- fclose (fp);
- }
- }
-