Name

sscanf

Synopsis

Reads formatted data from a string

#include <stdio.h>
intsscanf( const char * restrict src, const char * restrict format, ... );

The sscanf() function is similar to scanf(), except that it reads input items from the string addressed by its first pointer argument, src, rather than from stdin. Reading to the null character before the entire format string has been processed causes an input failure.

Example

See the examples at fscanf() and strspn() in this chapter.

See Also

scanf(), fscanf(), and sscanf(), declared in stdio.h; vscanf(), vsscanf(), and vfscanf(), declared in stdarg.h; fwscanf(), wscanf(), vwscanf(), vfwscanf(), and vswscanf(), declared in wchar.h; the printf() output functions. Argument conversion in the scanf() family of functions is described in detail under scanf() in this chapter.

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.