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 _vsnprintf( char *buf,
                    size_t count,
                    const char *format,
                    va_list arg );
    #include <stdarg.h>
    #include <wchar.h>
    int _vsnwprintf( wchar_t *buf,
                    size_t count,
                    const wchar_t *format,
                    va_list arg );

Description:
    The _vsnprintf function formats data under control of the format control
    string and stores the result in buf.  The maximum number of characters
    to store, including a terminating null character, is specified by count.
     The format string is described under the description of the  printf
    function.  The _vsnprintf function is equivalent to the  _snprintf
    function, with the variable argument list replaced with arg, which has
    been initialized by the  va_start macro.

    The _vsnwprintf function is identical to _vsnprintf 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 _vsnwprintf function accepts a wide-character
    string argument for format

Returns:
    The _vsnprintf function returns the number of characters written into
    the array, not counting the terminating null character, or a negative
    value if count or more characters were requested to be generated.  An
    error can occur while converting a value for output.  The _vsnwprintf
    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.  When an
    error has occurred,  errno contains a value indicating the type of error
    that has been detected.

Example:
    The following shows the use of _vsnprintf 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: " );
        _vsnprintf( &msgbuf[7], 80-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:
    WATCOM

Systems:
     _vsnprintf - All, Netware

    _vsnwprintf - All

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

See Also: cprintf va_arg

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