Help us and donate little Bitcoins to pay the server costs: 1AXLPuRUBYc1JczTW4XS65GL6oWjNP2Vt2

User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer







because of the inhumane working conditions at amazon in Germany, I will offer the Amazon app no more! (ARD Reportage)
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
advertising
c/stdio.h/sscanf.txt · Last modified: 2013/01/22 22:02 (external edit)

The new Question & Answer System is online and waiting for your Questions about Programming problems http://ask.code-reference.com Impressum