Converts formatted text in a character string to binary data.
#include <stdio.h> int sscanf(char *s, const char *format, ...);
s
A pointer to the character string from which to convert text to binary data.
format
The format string.
The sscanf() operates identically to scanf() but reads its input from the character array pointed to by s instead of stdin. The character array pointed to s must be null terminated.
scanf() returns the number of items successfully read and converted and returns EOF if it reaches the end of the string or a conversion specification does not match its argument.
This facility may not be available on configurations of the EWL that run on platformswithout file systems.
#include <stdio.h> int main(void) { char in[] = "figs cat pear 394 road 16!"; char s1[20], s2[20], s3[20]; int i; // get the words figs, cat, road, // and the integer 16 // from in and store them in s1, s2, s3, and i, // respectively sscanf(in, "%s %s pear 394 %s %d!", s1, s2, s3, &i); printf("%s %s %s %d\n", s1, s2, s3, i); return 0; } Output: figs cat road 16