Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdarg.h>
    #include <stdio.h>
    int vsprintf( char *buf,
                  const char *format,
                  va_list arg );
    #include <stdarg.h>
    #include <wchar.h>
    int vswprintf( wchar_t *buf,
                   size_t count,
                   const wchar_t *format,
                   va_list arg );

Description:
    The vsprintf function formats data under control of the format control
    string and writes the result to buf.  The format string is described
    under the description of the  printf function.  The vsprintf function is
    equivalent to the  sprintf function, with the variable argument list
    replaced with arg, which has been initialized by the  va_start macro.

    The vswprintf function is identical to vsprintf except that the argument
    buf specifies an array of wide characters into which the generated
    output is to be written, rather than converted to multibyte characters
    and written to a stream.  The maximum number of wide characters to
    write, including a terminating null wide character, is specified by
    count.  The vswprintf function accepts a wide-character string argument
    for format

Returns:
    The vsprintf function returns the number of characters written, or a
    negative value if an output error occurred.  The vswprintf function
    returns the number of wide characters written into the array, not
    counting the terminating null wide character, or a negative value if
    count or more wide characters were requested to be generated.

Example:
    The following shows the use of vsprintf in a general error message
    routine.

    #include <stdio.h>
    #include <stdarg.h>
    #include <string.h>

    char msgbuf[80];

    char *fmtmsg( char *format, ... )
      {
        va_list arglist;

        va_start( arglist, format );
        strcpy( msgbuf, "Error: " );
        vsprintf( &msgbuf[7], format, arglist );
        va_end( arglist );
        return( msgbuf );
      }

    void main()
      {
        char *msg;

        msg = fmtmsg( "%s %d %s", "Failed", 100, "times" );
        printf( "%s\n", msg );
      }

Classification:
    vsprintf is ANSI, vswprintf is ANSI

Systems:
     vsprintf - All, Netware

    vswprintf - All

See Also:
    _bprintf, cprintf, fprintf, printf, sprintf, va_arg, va_end, va_start,
    _vbprintf, vcprintf, vfprintf, vprintf

See Also: cprintf va_arg

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson