#include /* including standard library */
//#include /* uncomment this for Windows */
int sscanf(const char *str, const char *format, ...);
sscanf reads formatted input text from the string addressed by source .\\
No file input is performed. Following the format in the argument list may be one or more additional pointers addressing storage where the input values are stored.
The string pointed to by format is in the same form as that used by fscanf.\\
Refer to the fscanf description for detailed information concerning the formatting conventions.
/*
* sscanf example code
* http://code-reference.com/c/stdio.h/sscanf
*/
#include /* including standard library */
//#include /* uncomment this for Windows */
int main ( void )
{
char input[60];
char first[20];
char middle[20];
char last[20];
printf("Enter your full name: ");
gets(input); // no comment
sscanf(input, "%s %s %s", first, middle, last);
printf("Your middle name is: ");
printf("%s\n", middle);
return 0;
}
user@host:~$ ./sscanf
Enter your full name: John Mike Doe
Your middle name is: Mike