Ask a questionAsk a question
 

AnswerCtime

  • Tuesday, November 03, 2009 6:26 PMUser_Help Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I've been trying to use the <ctime> to store time variables. I need the hours, mins, and secs in separate variables. Can this be done with <ctime>? And everywhere I look for <ctime> help, I find <time.h>, whats up with that? 

    Thanks for any help 

Answers

  • Tuesday, November 03, 2009 7:50 PMcrescens2k Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    ctime is a safe include for time.h so that is really why you are getting this.

    So the documentation you should look at is the time functions in the runtime routines. (http://msdn.microsoft.com/en-us/library/w4ddyt9h.aspx for time)

    The two functions you want in particular are gmtime and mktime. gmtime reads a time_t and converts it to a tm structure, mktime takes a tm structure and outputs a time_t.
    Visit my (not very good) blog at http://c2kblog.blogspot.com/

All Replies