1#include <stdio.h>
2
3int
4main (int arc, char *argv[])
5{
6 int n, res;
7 unsigned int val;
8 char s[] = "111";
9 int result = 0;
10
11 n = 0;
12 res = sscanf(s, "%u %n", &val, &n);
13
14 printf(format: "Result of sscanf = %d\n", res);
15 printf(format: "Scanned format %%u = %u\n", val);
16 printf(format: "Possibly scanned format %%n = %d\n", n);
17 result |= res != 1 || val != 111 || n != 3;
18
19
20 result |= sscanf ("", " %n", &n) == EOF;
21
22 puts (s: result ? "Test failed" : "All tests passed");
23
24 return result;
25}
26

source code of glibc/stdio-common/bug10.c