locale: ld-telephone: update to ISO-30112 2014
[glibc.git] / stdio-common / scanf4.c
blob9bb14bb16bee036695836916caa94c8729f5f8e0
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <libc-internal.h>
5 int
6 main(int arc, char *argv[])
8 int res;
9 unsigned int val;
11 FILE *fp = fopen ("/dev/null", "r");
13 val = 0;
14 res = fscanf(fp, "%n", &val);
16 printf("Result of fscanf %%n = %d\n", res);
17 printf("Scanned format = %d\n", val);
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");
23 res = fscanf(fp, "");
25 DIAG_POP_NEEDS_COMMENT;
27 printf("Result of fscanf \"\" = %d\n", res);
28 if (res != 0)
29 abort ();
31 res = fscanf(fp, "BLURB");
32 printf("Result of fscanf \"BLURB\" = %d\n", res);
33 if (res >= 0)
34 abort ();
36 fclose (fp);
38 return 0;
39 return 0;