sscanf

Navigation:  Programming language SQC > Built-in functions > Output >

sscanf

Previous pageReturn to chapter overviewNext page

The function sscanf reads formatted input from a string.

On success, the function returns the number of variables filled.

 

int sscanf(char *s, char* format, ...)

 

Example:

 

int main () 

{

   int

     day, 

     no,

     year;

   

   char weekday[20], 

        month[20], 

        dtm[100];

 

   strcpy( dtm, "Thursday May 16 2019" );

   no = sscanf( dtm, "%s %s %d  %d", weekday, month, &day, &year );

 

   printf("%s %d %d is a %s\n", month, day, year, weekday );

    

   return(0);

}

 

Output:

  

  May 16 2019 is a Thursday