11 sscanf ("abc ", "abc %n", &n
);
12 printf ("t1: count=%d\n", n
);
24 #define SCAN(INPUT, FORMAT, VAR, EXP_RES, EXP_VAL) \
26 retval = sscanf (INPUT, FORMAT, &VAR); \
27 printf ("sscanf (\"%s\", \"%s\", &x) => %d, x = %ld\n", \
28 INPUT, FORMAT, retval, (long int) VAR); \
29 result |= retval != EXP_RES || VAR != EXP_VAL
31 SCAN ("12345", "%ld", N
, 1, 12345);
32 SCAN ("12345", "%llllld", N
, 0, -1);
33 SCAN ("12345", "%LLLLLd", N
, 0, -1);
34 SCAN ("test ", "%*s%n", n
, 0, 4);
35 SCAN ("test ", "%2*s%n", n
, 0, -1);
36 SCAN ("12 ", "%l2d", n
, 0, -1);
37 SCAN ("12 ", "%2ld", N
, 1, 12);
41 retval
= sscanf ("1 1", "%d %Z", &n
, &N
);
42 printf ("sscanf (\"1 1\", \"%%d %%Z\", &n, &N) => %d, n = %d, N = %ld\n", \
44 result
|= retval
!= 1 || n
!= 1 || N
!= -1;
56 snprintf (buf
, sizeof buf
, "%f %F", DBL_MAX
* DBL_MAX
- DBL_MAX
* DBL_MAX
,
57 DBL_MAX
* DBL_MAX
- DBL_MAX
* DBL_MAX
);
58 result
= strcmp (buf
, "nan NAN") != 0;
59 printf ("expected \"nan NAN\", got \"%s\"\n", buf
);
61 snprintf (buf
, sizeof buf
, "%f %F", DBL_MAX
* DBL_MAX
, DBL_MAX
* DBL_MAX
);
62 result
|= strcmp (buf
, "inf INF") != 0;
63 printf ("expected \"inf INF\", got \"%s\"\n", buf
);
65 swprintf (wbuf
, sizeof wbuf
/ sizeof (wbuf
[0]), L
"%f %F",
66 DBL_MAX
* DBL_MAX
- DBL_MAX
* DBL_MAX
,
67 DBL_MAX
* DBL_MAX
- DBL_MAX
* DBL_MAX
);
68 result
|= wcscmp (wbuf
, L
"nan NAN") != 0;
69 printf ("expected L\"nan NAN\", got L\"%S\"\n", wbuf
);
71 swprintf (wbuf
, sizeof wbuf
/ sizeof (wbuf
[0]), L
"%f %F",
72 DBL_MAX
* DBL_MAX
, DBL_MAX
* DBL_MAX
);
73 result
|= wcscmp (wbuf
, L
"inf INF") != 0;
74 printf ("expected L\"inf INF\", got L\"%S\"\n", wbuf
);
80 main (int argc
, char *argv
[])
88 result
|= fflush (stdout
) == EOF
;