1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5. #include <signal.h>
  6.  
  7. int main(int argc, char *argv[]) {
  8. FILE *fp2;
  9. fp2 = fopen(argv[1], "w");
  10. char input[10000];
  11. char temp[10000];
  12. char *pch;
  13. time_t current;
  14.  
  15.     if (argv[1]==NULL) {
  16.         printf("No file name specified");
  17.     }
  18.     else {
  19.         while (fgets(input, sizeof(input), stdin)) {
  20.             strcpy(temp, input);
  21.             time(&current);
  22.             strcpy(input, ctime(&current));
  23.             pch=strchr(input, '\n');
  24.             strcpy(pch, " ");
  25.             strcat(input, temp);
  26.             fprintf(fp2, "%s", input);
  27.         }
  28.     }  
  29. return 0;
  30. }