cpp/io/c/ungetc

If does not equal eof, pushes the character  (reinterpreted as ) into the input buffer associated with the stream  in such a manner than subsequent read operation from  will retrieve that character. The external device associated with the stream is not modified.

Stream repositioning operations std, std, and std discard the effects of.

If is called more than once without an intervening read or repositioning, it may fail (in other words, a pushback buffer of size 1 is guaranteed, but any larger buffer is implementation-defined). If multiple successful were performed, read operations retrieve the pushed-back characters in reverse order of

If equals eof, the operation fails and the stream is not affected.

A successful call to clears the end of file status flag std.

A successful call to on a binary stream decrements the stream position indicator by one (the behavior is indeterminate if the stream position indicator was zero).

A successful call to on a text stream modifies the stream position indicator in unspecified manner but guarantees that after all pushed-back characters are retrieved with a read operation, the stream position indicator is equal to its value before.

Return value
On success is returned.

On failure eof is returned and the given stream remains unchanged.