ungetc

Pushes a character back onto the specified input stream.

Library:LibC
Classification:ANSI
Service:File and Directory I/O

Syntax

  #include <stdio.h> 
   
  int ungetc (
     int    c,
     FILE   *fp);
  

Parameters

c

(IN) Specifies the byte to be pushed back onto the specified input stream.

fp

(IN) Points to the input stream.

Return Values

If successful, returns the character pushed back. Otherwise, returns EOF.

Remarks

The ungetc function pushes the character specified by c (converted to an unsigned char) back onto the input stream specified by fp. This character is returned by the next read from the stream. Only the last character returned in this way is remembered.

The ungetc function clears the EOF indicator, unless the value of c is EOF.

See Also