Mail Archives: djgpp/1998/09/29/21:53:47
tonyblaha AT juno DOT com wrote:
>
> I'm having trouble with the strftime() function in time.h.
> I've copied the example directly from libc.inf:
> But I can't get it to work.
The example is a little confusing, in that is doesn't mention that t
needs to be filled out.
time_t current_time;
struct tm* t;
char buf[100];
current_time = time(NULL); // get the current system time
t = localtime(¤t_time); // adjust for local parameters
strftime(buf, 100, "%B %d, %Y", &t); // format it to your taste
puts(buf); // and print it
note that 'localtime' or 'gmtime' return a pointer to a static buffer
that they maintain.
- Raw text -