2015-02-17 Steve Ellcey <sellcey@imgtec.com>
[glibc.git] / stdio-common / scanf9.c
blob7aca354d2a786f7612981023bb000ebba1a5d315
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
5 int
6 main (void)
8 int matches;
9 char str[10];
11 str[0] = '\0';
12 matches = -9;
13 matches = sscanf ("x ]", "%[^] ]", str);
14 printf ("Matches = %d, string str = \"%s\".\n", matches, str);
15 printf ("str should be \"x\".\n");
17 if (strcmp (str, "x"))
18 abort ();
20 str[0] = '\0';
21 matches = -9;
22 matches = sscanf (" ] x", "%[] ]", str);
23 printf ("Matches = %d, string str = \"%s\".\n", matches, str);
24 printf ("str should be \" ] \".\n");
26 if (strcmp (str, " ] "))
27 abort ();
29 return 0;