I am planning to implement #include <time.h> in my program. I have never yet used this include. I will be using this in order to track a 24-hour period, or at least that is what I wish to do; I basically need to set up a natural 24-hour day that I will be able to access and use at different, undetermined points in time, like a standard, analog clock-- I will need to be able to "tell the time". I will be using this time (when accessed) in a control statement. It would be great if is simply a variable that I would be accessing or if it could be dumped into a variable for use.

I am not asking for help with the program (design, logic, etc). I simply am seeing if anyone would be kind enough to share any thoughts, warnings, hazards, or general concerns about using time.h in a C++ program. Perhaps time.h is the incorrect include for what I am seeking to do?

Thank-you in advance for any reply.

[EDIT] With further thought, the tracking of the 24-hours in a direct, static sense would only last for the life of the program at the most (?) The program runs -> Time data saved in a variable would be active here -> This data would be dumped at program end. I suppose I will somehow have to make use of the system time for this-- perhaps I will just have to simulate the 24-day by using 24-milliseconds. Perhaps a RNG instead which provides a integer representing a specific hour? Actually, the user will not know and truthfully it should not matter how I do this-- the program is a simulator of sorts, so in essence, all is faked. Just thinking.

Looks like you will be better off using one of the functions given in this page. All the info you need to use those functions are also given there. So nothing to worry about.

This question has already been answered. Start a new discussion instead.