localtime vs localtime_s and appropriate input arguments

localtime returns a pointer to a statically allocated struct tm.

With localtime_s, you pass in a pointer to a struct tm, and localtime_s writes its result data into that, so your code would change from:

struct tm *timeinfo;
timeinfo = localtime(&rawtime);

to something like:

struct tm timeinfo;
localtime_s(&timeinfo, &rawtime);

This way, it’s writing to your buffer instead of having a buffer of its own.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)