previous | start | next

Example: sscanf

    1   char line[120];
    2   int x;
    3   float y;
    4   double z;
    5   int n;
    6   
    7   printf("Enter one line containing an integer, a float, and a double.\n");
    8   fgets(line, 120, stdin);
    9   n = sscanf(line, "%d %f %lf", &x, &y, &z);
   10   if ( n < 3 ) {
   11     printf("Invalid input. Only %d items successfully read.\n", n);
   12   }


previous | start | next