1.\" Copyright (c) 1990, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Chris Torek. 6.\" %sccs.include.redist.man% 7.\" 8.\" @(#)ungetc.3 6.5 (Berkeley) 04/19/91 9.\" 10.Dd 11.Dt UNGETC 3 12.Os 13.Sh NAME 14.Nm ungetc 15.Nd un-get character from input stream 16.Sh SYNOPSIS 17.Fd #include <stdio.h> 18.Ft int 19.Fn ungetc "int c" "FILE *stream" 20.Sh DESCRIPTION 21The 22.Fn ungetc 23function pushes the character 24.Fa c 25(converted to an unsigned char) 26back onto the input stream pointed to by 27.Fa stream . 28The pushed-backed characters will be returned by subsequent reads on the 29stream (in reverse order). 30A successful intervening call, using the same stream, to one of the file 31positioning functions 32.Po 33.Xr fseek 3 , 34.Xr fsetpos 3 , 35or 36.Xr rewind 3 37.Pc 38will discard the pushed back characters. 39.Pp 40One character of push-back is guaranteed, 41but as long as there is 42sufficient memory, an effectively infinite amount of pushback is allowed. 43.Pp 44If a character is successfully pushed-back, 45the end-of-file indicator for the stream is cleared. 46.Sh RETURN VALUES 47The 48.Fn ungetc 49function 50returns 51the character pushed-back after the conversion, or 52.Dv EOF 53if the operation fails. 54If the value of the argument 55.Fa c 56character equals 57.Dv EOF , 58the operation will fail and the stream will remain unchanged. 59.Sh SEE ALSO 60.Xr getc 3 , 61.Xr fseek 3 , 62.Xr setvbuf 3 63.Sh STANDARDS 64The 65.Fn ungetc 66function conforms to 67.St -ansiC . 68