User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:stdio.h:sscanf
#include <stdio.h> /* including standard library */
//#include <windows.h> /* 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 <stdio.h> /* including standard library */
//#include <windows.h> /* 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

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/stdio.h/sscanf.txt · Last modified: 2024/02/16 01:05 (external edit)

Impressum Datenschutz