I am trying to send a time_t to a function by using a time_t pointer variable. I don't get any compiler warnings when compiling my code, but a valgrind error when I run the code with valgrind.
My code:
printTime(time_t *time){
<prints time>
}
int main(void){
struct tm beginTime = {0};
time_t *begin = 0;
strptime("2012",""%Y,&beginTime);
beginTime.tm_isdst = -1;
*begin = mktime(&beginTime); **<-- Valgrind error points here**
printTime(begin);
return 0;
}
This is the valgrind error I am getting:
Invalid write of size 8. (Points at the location pointed at above)