| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #include <stdio.h> | 
|  | 2 | #include <stdlib.h> | 
|  | 3 | #include <string.h> | 
|  | 4 |  | 
|  | 5 | int | 
|  | 6 | main (void) | 
|  | 7 | { | 
|  | 8 | int matches; | 
|  | 9 | char str[10]; | 
|  | 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"); | 
|  | 16 |  | 
|  | 17 | if (strcmp (str, "x")) | 
|  | 18 | abort (); | 
|  | 19 |  | 
|  | 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"); | 
|  | 25 |  | 
|  | 26 | if (strcmp (str, " ] ")) | 
|  | 27 | abort (); | 
|  | 28 |  | 
|  | 29 | return 0; | 
|  | 30 | } |