Zeroing the tm struct sets all the fields to 0 and yields the date that you see (the year value has 1900 added to it and the month value has 1 added to it for display purposes). However, that date is not the epoch time. To see the epoch time (which is Midnight, Jan 1, 1970) you can do the following:
Code:
#include <stdio.h>
#include <time.h>
int main() {
time_t t = 0; // 0 time_t value represents the epoch
printf("%s\n", asctime(gmtime(&t))); // Thu Jan 1 00:00:00 1970
return 0;
}
To ensure that the tm struct is zeroed (if that's what you mean by "empty") you need to use memset like you did. I guess you could check that tm_mday is still 0 to check that it hasn't been set since you zeroed it:
Code:
if (t.tm_mday == 0) // day has not been set
{
}