Read the manual
Code:
NOTES
The four functions acstime(), ctime(), gmtime() and localtime() return
a pointer to static data and hence are not thread‐safe.
Since localtime() returns a pointer to static data, you can only use one at one, unless you save the result elsewhere
Code:
time_t now;
struct tm tm_now;
struct tm tm_later;
now = time ( NULL );
tm_now = *localtime ( &now );
tm_later = *localtime ( &now );
tm_later.tm_hour = 12;
printf ( "%s", asctime ( &tm_now ) );
printf ( "%s", asctime ( &tm_later ) );