User Tools

Site Tools


c:stdio.h:sscanf

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:stdio.h:sscanf [2013/01/22 22:02] (current)
Line 1: Line 1:
 +
 +<code c>
 +#include <stdio.h> /* including standard library */
 +//#include <windows.h> /* uncomment this for Windows */
 +
 +    int sscanf(const char *str, const char *format, ...);
 +</code>
 +
 +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.
 +
 +
 +  
 +<code c>
 +/* 
 + * 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;
 +}
 +
 +
 +
 +</code>
 +
 +    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)

Impressum Datenschutz