Re: va__list and pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Fco. J" wrote:

> > unsigned char *t_ctime()
> > {
> > time_t tim;
> > tim=time(NULL);
> > sleep(1);
> > return(ctime(&tim));
> > }

The behavior you are seeing has nothing to do with gcc or printf or
va_args or anything else.  It's because ctime() returns a static
buffer.  (Read its documentation.)  Because of this you must always use
the result of a call to ctime() before calling it again because each
call will overwrite that same buffer.  Try ctime_r() instead.

You should really find a general C language list or newsgroup for these
questions, because this is not gcc-specific.

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux