Get the current cross-platform time in C ++

How can I get the current time (I need hours, minutes, seconds) cross-platform in C ++? I have seen a value structure here, but there is a lot of other material that I do not need. Memory is important here.

+3
source share
1 answer

The subroutines in <time.h>are cross-platform and in fact should be available to comply with ISO C implementations. Use timeto get the elapsed time since 1970 and localtimeor gmtimeto break this down in a matter of hours, minutes and seconds.

You should not worry about struct tmusing too much memory to store unnecessary fields unless you program extremely memory-limited devices, in which case you are probably not looking for a cross-platform solution.

+8
source

Source: https://habr.com/ru/post/1737413/


All Articles