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.
time_t; what bothers me is having to save it as a pointer, because then I have to deal with a triple line of pointers and I'm already overwhelmed enough as it is with deleting the two iterations of pointers I presently have. If I saved it as a regulartime_t, how would I turn it into a pointer to be used byctime()?&operator to get a pointer from a variable. example:&array[i]->mod_time