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 <stdio.h>
    int _snprintf( char *buf,
                   size_t count,
                   const char *format, ... );
    #include <wchar.h>
    int _snwprintf( wchar_t *buf,
                    size_t count,
                    const wchar_t *format, ... );

Description:
    The _snprintf function is equivalent to the  fprintf function, except
    that the argument buf specifies a character array into which the
    generated output is placed, rather than to a file.  A null character is
    placed at the end of the generated character string.  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 _snwprintf function is identical to _snprintf 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 store, including a terminating null wide character, is
    specified by count.  The _snwprintf function accepts a wide-character
    string argument for format

Returns:
    The _snprintf 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 _snwprintf 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:
    #include <stdio.h>

    /* Create temporary file names using a counter */

    char namebuf[13];
    int  TempCount = 0;

    char *make_temp_name()
      {
        _snprintf( namebuf, 13, "ZZ%.6o.TMP", TempCount++ );
        return( namebuf );
      }

    void main()
      {
        FILE *tf1, *tf2;

        tf1 = fopen( make_temp_name(), "w" );
        tf2 = fopen( make_temp_name(), "w" );
        fputs( "temp file 1", tf1 );
        fputs( "temp file 2", tf2 );
        fclose( tf1 );
        fclose( tf2 );
      }

Classification:
    WATCOM

Systems:
     _snprintf - All, Netware

    _snwprintf - All

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

See Also: cprintf vcprintf

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