Time Stamp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • odin607
    New Member
    • Jun 2008
    • 19

    Time Stamp

    In C, and on a windows system, how would you place a timestamp on a file.

    I just want the file I'm writing to, to look like this

    numbers
    more numbers
    even more numbers
    yet even more numbers
    month/day/year

    would be nice to be able to tell when the last time i ran the program was =)
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Something like the following could do the job:

    [code=c]
    /* print all you numbers first */
    ...
    /* print the time stamp */
    fprintf(fd, ctime(time(NULL )));
    [/code]

    kind regards,

    Jos

    Comment

    • odin607
      New Member
      • Jun 2008
      • 19

      #3
      what other code do I need (libraries/declarations), Im not familiar with the code snippet

      looks promising though =x!

      Comment

      • gpraghuram
        Recognized Expert Top Contributor
        • Mar 2007
        • 1275

        #4
        Originally posted by odin607
        what other code do I need (libraries/declarations), Im not familiar with the code snippet

        looks promising though =x!

        You should use time.h and all C related time functions are in that header file.


        Raghu

        Comment

        • odin607
          New Member
          • Jun 2008
          • 19

          #5
          all set, thanks for reminding me about time.h :P

          http://www.cplusplus.c om/reference/clibrary/ctime/time.html

          used this (though modified it for what I needed)

          This problem: Solved

          Comment

          Working...