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;
49 volatile double nanval
;
61 snprintf (buf
, sizeof buf
, "%f %F", nanval
, nanval
);
62 result
= strcmp (buf
, "nan NAN") != 0;
63 printf ("expected \"nan NAN\", got \"%s\"\n", buf
);
65 snprintf (buf
, sizeof buf
, "%f %F", DBL_MAX
* DBL_MAX
, DBL_MAX
* DBL_MAX
);
66 result
|= strcmp (buf
, "inf INF") != 0;
67 printf ("expected \"inf INF\", got \"%s\"\n", buf
);
69 swprintf (wbuf
, sizeof wbuf
/ sizeof (wbuf
[0]), L
"%f %F", nanval
, nanval
);
70 result
|= wcscmp (wbuf
, L
"nan NAN") != 0;
71 printf ("expected L\"nan NAN\", got L\"%S\"\n", wbuf
);
73 swprintf (wbuf
, sizeof wbuf
/ sizeof (wbuf
[0]), L
"%f %F",
74 DBL_MAX
* DBL_MAX
, DBL_MAX
* DBL_MAX
);
75 result
|= wcscmp (wbuf
, L
"inf INF") != 0;
76 printf ("expected L\"inf INF\", got L\"%S\"\n", wbuf
);
82 main (int argc
, char *argv
[])
90 result
|= fflush (stdout
) == EOF
;