vscanf, vfscanf and vsscanf [C++ Reference]
Keywords: c,io,vscanf_vfscanf_vsscanf
Date: 2008-10-14T15:42:01-0700

[[vscanf, vfscanf and vsscanf]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## vscanf, vfscanf and vsscanf

Syntax:

        #include <cstdarg>
        #include <cstdio>
        int vscanf( char *format, va_list arg_ptr );
        int vfscanf( FILE *stream, const char *format, va_list arg_ptr );
        int vsscanf( char *buffer, char *format, va_list arg_ptr );

These functions are very much like scanf(), fscanf(), and sscanf(). 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:

         int scanf_( char *fmt, ... ) {
           va_list args;
           va_start( args, fmt );
           int r = vscanf(frmt, args);
           scanf("%*[^\n]"), getchar(); //Empty buffer
           va_end( args );
           return r;
         }

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