1 /* Taken from the Li18nux base test suite. */
3 #define _XOPEN_SOURCE 500
14 const char *str
= "abcdef";
16 char fname
[] = "/tmp/tst-ungetwc2.out.XXXXXX";
21 puts ("This program runs on de_DE.UTF-8 locale.");
22 if (setlocale (LC_ALL
, "de_DE.UTF-8") == NULL
)
24 fprintf (stderr
, "Err: Cannot run on the de_DE.UTF-8 locale\n");
28 /* Write some characters to `testfile'. */
32 printf ("cannot open temp file: %m\n");
35 if ((fp
= fdopen (fd
, "w")) == NULL
)
37 fprintf (stderr
, "Cannot open 'testfile'.\n");
43 /* Open `testfile'. */
44 if ((fp
= fopen (fname
, "r")) == NULL
)
46 fprintf (stderr
, "Cannot open 'testfile'.");
50 /* Get a character. */
53 printf ("After get a character: %ld\n", pos
);
57 /* Unget a character. */
58 ret
= ungetwc (wc
, fp
);
61 fprintf (stderr
, "ungetwc() returns NULL.");
65 printf ("After unget a character: %ld\n", pos
);
69 /* Reget a character. */
72 printf ("After reget a character: %ld\n", pos
);