]> git.ipfire.org Git - thirdparty/glibc.git/blame - stdio-common/scanf3.c
Improve documentation for malloc etc. (BZ#27719)
[thirdparty/glibc.git] / stdio-common / scanf3.c
CommitLineData
a66067be
RM
1#include <stdio.h>
2#include <stdlib.h>
3
11336c16
UD
4int
5main(int arc, char *argv[])
a66067be
RM
6{
7 int n, res;
8 unsigned int val;
11336c16 9 char s[] = "111";
a66067be
RM
10
11 val = n = -1;
12 res = sscanf(s, "%u %n", &val, &n);
13 printf("Result of sscanf = %d\n", res);
14 printf("Scanned format %%u = %u\n", val);
15 printf("Possibly scanned format %%n = %d\n", n);
8d57beea 16 if (n != 3 || val != 111 || res != 1)
a66067be
RM
17 abort ();
18
19 val = n = -1;
20 res = sscanf(s, "%u%n", &val, &n);
21 printf("Result of sscanf = %d\n", res);
22 printf("Scanned format %%u = %u\n", val);
23 printf("Possibly scanned format %%n = %d\n", n);
8d57beea 24 if (n != 3 || val != 111 || res != 1)
a66067be
RM
25 abort ();
26
27 return 0;
a66067be 28}