Blame stdio-common/scanf9.c

Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <stdlib.h>
Packit 6c4009
#include <string.h>
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
main (void)
Packit 6c4009
{
Packit 6c4009
  int matches;
Packit 6c4009
  char str[10];
Packit 6c4009
Packit 6c4009
  str[0] = '\0';
Packit 6c4009
  matches = -9;
Packit 6c4009
  matches = sscanf ("x ]", "%[^] ]", str);
Packit 6c4009
  printf ("Matches = %d, string str = \"%s\".\n", matches, str);
Packit 6c4009
  printf ("str should be \"x\".\n");
Packit 6c4009
Packit 6c4009
  if (strcmp (str, "x"))
Packit 6c4009
    abort ();
Packit 6c4009
Packit 6c4009
  str[0] = '\0';
Packit 6c4009
  matches = -9;
Packit 6c4009
  matches = sscanf (" ] x", "%[] ]", str);
Packit 6c4009
  printf ("Matches = %d, string str = \"%s\".\n", matches, str);
Packit 6c4009
  printf ("str should be \" ] \".\n");
Packit 6c4009
Packit 6c4009
  if (strcmp (str, " ] "))
Packit 6c4009
    abort ();
Packit 6c4009
Packit 6c4009
  return 0;
Packit 6c4009
}