Reading info from files and printing them out. I save the modification time from stat
as an int
called mod_time
into a struct to recall later. However, when I want to use the ctime()
function, I run into a problem because that takes a time_t*
type variable. I tried using a typecast but that just resulted in a seg fault. Any help would be much appreciated.
void print(struct file_info **array)
{
int i;
for (i = 0; array[i] != NULL; i++)
{
printf("%s\n", array[i]->name);
printf("mod_time: %s\n", ctime((time_t*)array[i]->mod_time));
}
}
The above is the example with the typecast, which yielded a seg fault. The original one just excluded the (time_t*)
typecast, which resulted in a "without a cast" warning.