Re: passing a va_list to sprintf

From: Peter Pichler (pichlo6_at_pobox.sk)
Date: 10/31/03


Date: Fri, 31 Oct 2003 08:26:01 -0000


"Shea Martin" <shea@snowsquirrel.ca> wrote in message
news:kooob.230908$pl3.90584@pd7tw3no...
> I have a function:
>
> void f(char* format, ...)
> {
> va_list args;
> char buf[128];
> sprintf(buf, format, args);
> printf(buf);
> }
>
> But I can't get sprintf to properly take the args I have given to f(). I
can't
> seem to find any examples on passing a va_list.
>
> Any help would be appreciated.

Try vsprintf.



Relevant Pages

  • Re: Help with va_list, va_start
    ... void FormatTest(const TCHAR* format, ...) ... wvsprintf(buf, format, args); ... > // The test code ...
    (microsoft.public.vc.language)
  • Passing Variable Args
    ... void Log(const char* format, ...) ... va_list args; ... void DoLog1(const char* format, va_list* args) ...
    (comp.lang.c)
  • [Full-disclosure] Re: Format string in Doomsday 1.8.6
    ... Both Con_Message and conPrintf are vulnerable to a format string ... buffer = malloc; ... void conPrintf(int flags, const char *format, va_list args) ... vsprintf(message_buf, str, args); ...
    (Full-Disclosure)
  • Re: Format string in Doomsday 1.8.6
    ... Both Con_Message and conPrintf are vulnerable to a format string ... buffer = malloc; ... void conPrintf(int flags, const char *format, va_list args) ... vsprintf(message_buf, str, args); ...
    (Bugtraq)
  • Re: Safe to get address of va_list function parameter?
    ... void MyFunction1(const char *format, va_list args) ... MyFunctionCore(format, &args); ... the compiler will extract the data from the integer registers part. ...
    (comp.lang.c)