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

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