]> git.ipfire.org Git - thirdparty/glibc.git/blame - stdio-common/scanf4.c
NEWS: Add advisories.
[thirdparty/glibc.git] / stdio-common / scanf4.c
CommitLineData
a66067be 1#include <stdio.h>
3e1f480e 2#include <stdlib.h>
e15f7de6 3#include <libc-diag.h>
a66067be 4
11336c16
UD
5int
6main(int arc, char *argv[])
a66067be 7{
11336c16 8 int res;
a66067be
RM
9 unsigned int val;
10
11 FILE *fp = fopen ("/dev/null", "r");
12
13 val = 0;
14 res = fscanf(fp, "%n", &val);
15
16 printf("Result of fscanf %%n = %d\n", res);
17 printf("Scanned format = %d\n", val);
18
1c4053db
RM
19 /* We're testing exactly the case the warning is for. */
20 DIAG_PUSH_NEEDS_COMMENT;
21 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-zero-length");
22
a66067be 23 res = fscanf(fp, "");
1c4053db
RM
24
25 DIAG_POP_NEEDS_COMMENT;
26
a66067be
RM
27 printf("Result of fscanf \"\" = %d\n", res);
28 if (res != 0)
29 abort ();
30
31 res = fscanf(fp, "BLURB");
32 printf("Result of fscanf \"BLURB\" = %d\n", res);
33 if (res >= 0)
34 abort ();
35
36 fclose (fp);
37
38 return 0;
39 return 0;
40}