 | C251 User's Guide |  |
|
|
| ungetchar| Summary | | | 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. | | See Also | _getkey, getchar, putchar | | Example |
#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);
}
|
|
|