vfscanf

Scans input from a stream under format control, using a variable argument list.

Library:LibC
Classification:ANSI
Service:File and Directory I/O

Syntax

  #include <stdio.h> 
   
  int vfscanf (
     FILE         *fp,
     const char   *format,
     va_list       arg);
  

Parameters

fp

(IN) Points to the file.

format

(IN) Points to the format control string. See Scan Format Control Strings.

arg

(OUT) Specifies a variable argument list where the scanned string is to be stored. The number of arguments in the list is determined by the format string.

Return Values

If successful, returns the number of input items for which values were successfully scanned and stored. Otherwise, returns EOF when any of the following occur:

  • The scanning is terminated by reaching the end of the input stream

  • A matching failure is encountered

  • A read error occurs

If a read error occurs, vfscanf also sets the error indicator for the stream and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

The file descriptor is not valid for reading.

5

ENOMEM

Insufficient storage space is available.

9

EINVAL

The format string contains insufficient arguments.

24

EAGAIN

The O_NONBLOCK flag is set for the file descriptor, and the process cannot immediately perform the read operation.

25

ENXIO

A request was made of a nonexistent device, or the request was outside the capabilities of the device.

28

EIO

The process is orphaned and cannot write to the file.

63

EINTR

A signal interrupted the read operation.

81

EOVERFLOW

The file is a regular file and an attempt was made to read at or beyond the offset maximum associated with the corresponding stream.

101

EILSEQ

The input byte sequence does not form a valid character.

Remarks

The vfscanf function scans input from the file designated by fp under control of the format parameter and stores it in the arg parameter.

The vfscanf function is equivalent to the fscanf function, with the variable arguments replaced with arg, which has been initialized using the va_start macro.

See Also