logo

What is the ungetc function?

#include <stdio.h> #include <stdlib.h> #include <string.h> void f() { char c = getchar(); printf("Again the same result: %c\n", c); } int main(int argc, char* argv[]) { char c = getchar(); printf("Result: %c\n", c); int res = ungetc('f', stdin); if (res == EOF) { printf("Error\n"); } f(); return 0; }
Course thumb

The C programming language made simple