[Previous]
[Contents]
[Next]

vprintf()

write formatted output to a file

Synopsis:

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

int vprintf( const char *format, va_list arg );

Description:

The vprintf() function writes output to the file stdout, under control of the argument format. The format string is described under the description of the printf() function. The vprintf() function is equivalent to the printf() function, with the variable argument list replaced with arg, which has been initialized by the va_start() macro.

Returns:

The number of characters written, or a negative value if an output error occurred. If an error occurs, errno indicates the error detected.

Examples:

The following shows the use of vprintf() in a general error message routine:

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

void errmsg( char *format, ... )
  {
    va_list arglist;

    printf( "Error: " );
    va_start( arglist, format );
    vprintf( format, arglist );
    va_end( arglist );
  }

void main()
  {
    errmsg( "%s %d %s", "Failed", 100, "times" );
  }

Classification:

ANSI

Safety:
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

_bprintf(), cprintf(), errno, fprintf(), printf(), sprintf(), va_arg(), va_end(), va_start(), _vbprintf(), vcprintf(), vfprintf(), vsprintf()


[Previous]
[Contents]
[Next]