ungetc()

Declaration

int ungetc(int iChar, FILE* qpStream);

Description:

This function puts the character "iChar" into the stream "qpStream" at the current internal file pointer location after a character has been read. If successful, the function returns the character that put into the stream, or it returns EOF if an error occurs.

Example

#include <cstdio>

int main()
{
    for (int i = 0; i < 8; ++i) {
        int iChar = getchar();
        // Put the second 'X' back so that
        // we get it next time.
        if (i == 3) {
            ungetc(iChar, stdin);
        }
        printf("%c\n", (char)iChar);
    }

    return 0;
}

Output:

signal() Output