sscanf

Scans input from a character string under format control.

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

Syntax

  #include <stdio.h> 
   
  int sscanf (
     const char   *string,   
     const char   *format,   
     ... );
  

Parameters

string

(IN) Points to a character string to scan.

format

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

...

(IN) Points to where the converted string is to be stored. The number of arguments is determined by the format string.

Return Values

If successful, returns the number of input arguments 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, sscanf 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.

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.

See Also