#include <stdio.h>
char ungetchar (
char c); /* character to unget */
Description
The ungetchar function stores the character c back into the input stream. The next call to
getchar or any other stream input function returns c. Only one character may be passed to unget between calls
to getchar.
Return Value
The ungetchar function returns the character c if successful. If ungetchar is called more than
once between function calls that read from the input stream, EOF is
returned indicating an error condition.
#include <stdio.h>
#include <ctype.h> /* for isdigit */
void tst_ungetchar (void) {
char k;
while (isdigit (k = getchar ())) {
/* stay in the loop as long as k is a digit */
}
ungetchar (k);
}
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.