sscanf()                 Read Formatted Data from String
 
 #include   <stdio.h>
 
 int        sscanf(buffer,format-string[[,argument...]]);
 char       *buffer;                     Stored data
 char       *format-string;              Format control string
 
    sscanf() reads data from 'buffer' into the locations given by
    'arguments'.  sscanf() operates identically to scanf(), with the
    single exception that scanf() reads data from stdin, while sscanf()
    reads data from 'buffer'.  The format-string, arguments, and return
    value of sscanf() are the same as those of scanf(); see the scanf()
    function for a complete description.
 
  -------------------------------- Example ---------------------------------
 
    This example scans 'buffer' for the given fields, which are then
    printed.
 
          #include <stdio.h>
 
          char *buffer = "001Smith,J 002Jones,B";
          int num, numread, num2;
          char name[15], name2[15];
 
          main()
          {
               numread = sscanf(buffer,"%3d %15s %3d %15s",
                                &num,name,&num2,name2);
               printf("number of fields read: %d \n",numread);
               printf("employee: %s (%d)\n",name,num);
               printf("employee: %s (%d)\n",name2,num2);
 
           }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster