vfscanf(), vscanf(), vsscanf() — Format input of a STDARG argument list

Standards

Standards / Extensions C or C++ Dependencies

C99
Single UNIX Specification, Version 3
Language Environment
C++ TR1 C99

both z/OS® V1R7

Format

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

int vfscanf(FILE *__restrict__ stream, 
            const char *__restrict__ format, va_list arg);

int vscanf(const char *__restrict__ format, va_list arg);

int vsscanf(const char *__restrict__ s, 
            const char *__restrict__ format, va_list arg);

#define _OPEN_SYS_UNLOCKED_EXT 1
#include <stdio.h>

int vfscanf_unlocked(FILE *__restrict__ stream, 
            const char *__restrict__ format, va_list arg);

int vscanf_unlocked(const char *__restrict__ format, va_list arg);

General description

The vfscanf(), vscanf(), and vsscanf() functions are equivalent to the fscanf(), scanf(), and sscanf() functions, respectively, except that instead of being called with a variable number of arguments, they are called with an argument list as defined in stdarg.h.

The argument list should be initialized using the va_start macro before each call. These functions do not invoke the va_end macro, but instead invoke the va_arg macro causing the value of arg after the return to be unspecified.

vfscanf() and vscanf() are not supported for files opened with a record type. They also have the same restrictions as a write immediately following a read or a read immediately following a write. This is because, between a write and a subsequent read, there must be an intervening flush or reposition and between a read and a subsequent write, there must also be an intervening flush or reposition unless EOF has been reached.

Note: In contrast to some UNIX-based implementations of the C language, the z/OS XL C/C++ implementation of the vscanf() family increments the pointer to the variable arguments list. To control whether the pointer is incremented, call the va_end macro after each function call.

vfscanf_unlocked() and vscanf_unlocked() are functionally equivalent to vfscanf() and vscanf() with the exception that they are not thread-safe. These functions may safely be used in a multithreaded application if and only they are called while the invoking thread owns the (FILE*) object, as is the case after a successful call to either the flockfile() or ftrylockfile() function.

Returned value

Refer to fscanf().

Related information