sscanf function(Formatted String Read) in C Language – example and detail

In the C Programming Language, the sscanf feature reads formatted output from an object pointed to with the aid of s.


The syntax for the sscanf characteristic in the C Language is:

int sscanf(const char *s, const char *format, ...);

Parameters or Arguments

stream An array where the output will be read. format Describes the input as properly as offers a placeholder to insert the formatted string. Here are a few examples: Format Explanation Example %d Reads an integer 10 %f Reads a floating-point variety in fixed decimal structure 10.500000 %.1f Reads a floating-point variety with 1 digit after the decimal 10.5 %e Reads a floating-point quantity in exponential (scientific notation) 1.050000e+01 %g Reads a floating-point quantity in either fixed decimal or exponential structure relying on the dimension of the number 10.5


The sscanf function returns the quantity of characters that used to be examine and stored. If an error happens or end-of-file is reached before any gadgets should be read, it will return EOF.

Required Header

In the C Language, the required header for the sscanf characteristic is:

#include <stdio.h>

Applies To

In the C Language, the sscanf feature can be used in the following versions:

ANSI/ISO 9899-1990

Similar Functions

Other C features that are similar to the sscanf function:

fscanf characteristic scanf function

See Also

Other C features that are noteworthy when dealing with the sscanf function:

fprintf feature printf characteristic sprintf function vfprintf characteristic vprintf feature vsprintf feature