ubuntu-buildroot/output/build/glibc-2.36-81-g4f4d7a13edfd.../stdio-common/scanf9.c

31 lines
566 B
C
Raw Permalink Normal View History

2024-04-01 15:19:46 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main (void)
{
int matches;
char str[10];
str[0] = '\0';
matches = -9;
matches = sscanf ("x ]", "%[^] ]", str);
printf ("Matches = %d, string str = \"%s\".\n", matches, str);
printf ("str should be \"x\".\n");
if (strcmp (str, "x"))
abort ();
str[0] = '\0';
matches = -9;
matches = sscanf (" ] x", "%[] ]", str);
printf ("Matches = %d, string str = \"%s\".\n", matches, str);
printf ("str should be \" ] \".\n");
if (strcmp (str, " ] "))
abort ();
return 0;
}