Each time you call localtime, it will overwrite a static structure and return the address of the structure (so at the same time inProgramOnly one such structure can be obtained, but no obvious copy can be made ). Strftime format the string according to the specified format (for example, % A represents the name of every day of the week ).
Http://develop.csai.cn/c/200805211459491305.htm
Localtime is NOT thread-safe, so using localtime in multiple threads may cause memory leakage.
Time_t now;
Time (& now); // The unit of the retrieved data is seconds.
Clock_t clockk;
Clockk = clock (); // million seconds millisecond, clocks_per_sec
Sleep (1000); Unit: milliseconds
Timer In cwnd cannot be accurate to milliseconds, and it is costly to use timer in cwnd. Because timer is derived from cwnd, As long as timer is used, it must have a cwnd object.
In the MFC class library, the following Windows API functions are encapsulated:
(1) timegetdevcaps to obtain the time precision of the current computer. Timecaps is a structure defined by the system.
(2) timebeginperiod: sets the precision of the current timer. This step is set to 5, indicating that the error is not greater than 5 ms.
(3) timeendperiod, which corresponds to 2, ends the timing precision.
(4) timesetevent. At the beginning of the timer, this function requires a number of callback letters and the parameters of the callback function as parameters. This program calls internaltimerproc, and the data struct parameter of mmrecord. This struct parameter specifies the timer ID and a pointer to the cmmstimers (which points to the timer ). (5) timekillevent. Terminate the timer.