Back to index

glibc  2.9
scanf9.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 
00005 int
00006 main (void)
00007 {
00008   int matches;
00009   char str[10];
00010 
00011   str[0] = '\0';
00012   matches = -9;
00013   matches = sscanf ("x ]", "%[^] ]", str);
00014   printf ("Matches = %d, string str = \"%s\".\n", matches, str);
00015   printf ("str should be \"x\".\n");
00016 
00017   if (strcmp (str, "x"))
00018     abort ();
00019 
00020   str[0] = '\0';
00021   matches = -9;
00022   matches = sscanf (" ] x", "%[] ]", str);
00023   printf ("Matches = %d, string str = \"%s\".\n", matches, str);
00024   printf ("str should be \" ] \".\n");
00025 
00026   if (strcmp (str, " ] "))
00027     abort ();
00028 
00029   return 0;
00030 }