I'm having problems converting from unix epoch time to a character array. I know how to do it and the conversion is happening correctly but after I make a call to gmtime() or localtime(), all input gets random characters appended to to. I have pinned the problem down and ONLY lines calling either localtime() or gmtime() cause this problem (seriously... I have them in and the problem occurs, I comment them out, remake, and the problem no longer occurs). Here is the function where the function is called:
void ls(){
int clusterSize = bootRecord[0];
int root = bootRecord[2];
for (int i = 0; i < bootRecord[0] / 128 ; ++i){
fseek(fp, clusterSize * root + 128 * i, SEEK_SET);
if(directoryTable[i].name[0] != 0x00){
time_t rawtime = (time_t)directoryTable[i].creation;
struct tm * curDate;
curDate = localtime(&rawtime);
printf("%s %d %s", directoryTable[i].name, directoryTable[i].size,
asctime(gmtime(&rawtime)));
}
}
}
Right now I have the asctime(gmtime(&rawtime)) but I have tried separating them into several different statements but to no avail. Does anyone know of a useful alternative to localtime() or gmtime()? Or happen to know a solution to this particular problem? Thank you.