Re: passing a va_list to sprintf

From: Shea Martin (smartin_at_arcis.com)
Date: 10/31/03


Date: Fri, 31 Oct 2003 08:46:39 -0700

Shea Martin wrote:
> 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.
>
> Thanks.
>
> ~S
>
Thanks for the solutions, worked perfect.
~S



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)
  • Re: passing a va_list to sprintf
    ... > sprintf(buf, format, args); ... > But I can't get sprintf to properly take the args I have given to f. ... What you want is vsprintf and not sprintf. ...
    (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)