c++ - Two separate tm structs mirroring each other -
Here's my current status:
- I have two TM strings, both set current Time
- I make changes in hours in one of the structures
- The change is decreasing magically in other structures ....
- How do I do this Prevent me from I should be able to compare and find the number of seconds between two different times - the present time and time in the future I'm using difftime and mktime to determine I think technically two TM stranks are not needed (other structures can only be loaded with raw time), but I'm interested in understanding why this happens.
zero tracker :: Monitor (four * buffer) {
// time-typing time_t system time, schedulatum, current time; Structure TM * dispatch time; Struct tm * uicatime; Double timeout; // We operate two strings with the current time dispatch = Dispat Time_TM (); Uiuctime = uiuctime_tm (); // Fixed parameter sending time-> Tm_hour = 5; Shipping Time- & gt; Tm_min = 05; Shipping Time- & gt; TM_SC = 14; Uicatime-> Tm_hour = 0; // Both of these will now print at the same time! (0:05:14) // what is adding them ?? // set time printf print ("Current time:% 2d:% 02d:% 02d \ n", uiuctime-> tm_hour, uiuctime-> tm_min, uiuctime-> tm_sec); Printf ("Scheduled time:% 2d:% 02d:% 02d \ n", sending time-> tm_hour, sending-time-> tm_min, sending time-> tm_sec);
}
struct tm * tracker :: uiuctime_tm () {time_t uiucTime; Struct tm * ts_uiuc; // Give current time the time of the current time (& amp; uiucTime); // change time zone to UIUC putenv ("TZ = CST6CDT"); Tzset (); // TZ selected local time for ts_uiuc = local time (& amp; uiucTime); // Set the current timezone uncertainty ("tees") back; Tzset (); // return our results back ts_uiuc set back; } Struct tm * Tracker :: Reminder Time_tm () {time_t currentTime; Structure TM * ts_dispatch; // present time in current time (and current time); // TZ selected ts_dispatch = get local time for local time (and current time); // our result returns ts_dispatch back set; }
You have to:
structure TM * temp_tm; Structure TM dispatch time; // Now a pointer structure tm uicatime; // Now an indicator temp_tm = sending_atam (); Sending time = * temp_tm; Member Member Member temp_tm = uiuctime_tm (); Uiuctime = * temp_tm; // member-per-member
In this way you will keep a local copy of the tm
struct. This structure is internally allocated in the standard library, Code> local time will be indicated on the same memory address!
Comments
Post a Comment