You need to allocate memory for the time()
function to store the result if you want to provide it as a parameter. Either declare the variable on the stack or call malloc()
. You can also retrieve the returned value if you give NULL
as a parameter.
time_t current_time_since_epoch;
time(¤t_time_since_epoch);
// or
current_time_since_epoch = time(NULL);
// or
time_t* timePtr = (time_t*) malloc(sizeof(time_t));
time(timePtr);
// ...
free(timePtr);
More info on the function time()
prototype here