vprintf, vfprintf, and vsprintf [C++ Reference]
Keywords: c,io,vprintf_vfprintf_vsprintf
Date: 2008-10-14T15:42:01-0700

[[vprintf, vfprintf, and vsprintf]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## vprintf, vfprintf, and vsprintf

Syntax:

        #include <cstdarg>
        #include <cstdio>
        int vprintf( char *format, va_list arg_ptr );
        int vfprintf( FILE *stream, const char *format, va_list arg_ptr );
        int vsprintf( char *buffer, char *format, va_list arg_ptr );

These functions are very much like printf(), fprintf(), and sprintf(). The difference is that the argument list is a pointer to a list of arguments. va_list is defined in cstdarg, and is also used by va_arg. For example:

         void error( char *fmt, ... ) {
           va_list args;
           va_start( args, fmt );
           fprintf( stderr, "Error: " );
           vfprintf( stderr, fmt, args );
           fprintf( stderr, "\n" );
           va_end( args );
           exit( 1 );
         }

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •