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