tags:

views:

246

answers:

1

Hello, How can I get current time (I need hours, minutes, seconds) crossplatform in c++? I saw here make structure of values but there are a lots of another stuff that I don't need. And memory is very important here.

+8  A: 

The routines in <time.h> are cross-platform and in fact required to be available for conforming implementations of ISO C. Use time to retrieve the elapsed time since 1970, and localtime or gmtime to break that down into hours, minutes, and seconds, as needed.

You shouldn't be concerned that struct tm uses too much memory to store unneeded fields unless you are programming extremely memory-constrained devices, in which case you probably aren't looking for a cross-platform solution.

Will
The routines in what are cross-platform? You seem to be missing a noun.
Sorry, I guess unescaped anglies in StackOverflow are a no-no. <time.h>Hello, world!</time.h>
Will