M
michelle
Hi, for the program I am coding now, I need to write the time as a
String to a file, and later need to compare that recorded time with
the current time. I have problem changing time from the string to the
unsigned int (to compare with t->tv_sec). So what I did first is
that:
struct timeval* t = (struct timeval*) malloc (sizeof(struct timeval));
gettimeofday(t, NULL);
t->tv-sec +=sec; (Use sec(any seconds) to calculate the expired time)
fprintf(file, "expire at %s\n", ctime(&(t->tv_sec))). (so print to a
file about when it expries)
And then later I need to convert this string back to unsigned int to
compare with the current time. Does anyone know how do I convert it
back if there is a way to do it? Thanks!
Michelle
String to a file, and later need to compare that recorded time with
the current time. I have problem changing time from the string to the
unsigned int (to compare with t->tv_sec). So what I did first is
that:
struct timeval* t = (struct timeval*) malloc (sizeof(struct timeval));
gettimeofday(t, NULL);
t->tv-sec +=sec; (Use sec(any seconds) to calculate the expired time)
fprintf(file, "expire at %s\n", ctime(&(t->tv_sec))). (so print to a
file about when it expries)
And then later I need to convert this string back to unsigned int to
compare with the current time. Does anyone know how do I convert it
back if there is a way to do it? Thanks!
Michelle