xref: /csrg-svn/lib/libc/stdio/ungetc.3 (revision 61180)
1*61180Sbostic.\" Copyright (c) 1990, 1991, 1993
2*61180Sbostic.\"	The Regents of the University of California.  All rights reserved.
320382Smckusick.\"
446107Sbostic.\" This code is derived from software contributed to Berkeley by
550337Sbostic.\" Chris Torek and the American National Standards Committee X3,
650337Sbostic.\" on Information Processing Systems.
750337Sbostic.\"
846107Sbostic.\" %sccs.include.redist.man%
946107Sbostic.\"
10*61180Sbostic.\"     @(#)ungetc.3	8.1 (Berkeley) 06/04/93
1146107Sbostic.\"
1248351Scael.Dd
1348351Scael.Dt UNGETC 3
1448351Scael.Os
1548351Scael.Sh NAME
1648351Scael.Nm ungetc
1748351Scael.Nd un-get character from input stream
1848351Scael.Sh SYNOPSIS
1948351Scael.Fd #include <stdio.h>
2048351Scael.Ft int
2148351Scael.Fn ungetc "int c" "FILE *stream"
2248351Scael.Sh DESCRIPTION
2348351ScaelThe
2448351Scael.Fn ungetc
2548351Scaelfunction pushes the character
2648351Scael.Fa c
2748351Scael(converted to an unsigned char)
2848351Scaelback onto the input stream pointed to by
2948351Scael.Fa stream .
3048351ScaelThe pushed-backed characters will be returned by subsequent reads on the
3148351Scaelstream (in reverse order).
3248351ScaelA successful intervening call, using the same stream, to one of the file
3348351Scaelpositioning functions
3448351Scael.Po
3548351Scael.Xr fseek 3 ,
3648351Scael.Xr fsetpos 3 ,
3748351Scaelor
3848351Scael.Xr rewind 3
3948351Scael.Pc
4048351Scaelwill discard the pushed back characters.
4148351Scael.Pp
4248351ScaelOne character of push-back is guaranteed,
4348351Scaelbut as long as there is
4446107Sbosticsufficient memory, an effectively infinite amount of pushback is allowed.
4548351Scael.Pp
4648351ScaelIf a character is successfully pushed-back,
4748351Scaelthe end-of-file indicator for the stream is cleared.
4848351Scael.Sh RETURN VALUES
4948351ScaelThe
5048351Scael.Fn ungetc
5148351Scaelfunction
5220382Smckusickreturns
5348351Scaelthe character pushed-back after the conversion, or
5448351Scael.Dv EOF
5548351Scaelif the operation fails.
5648351ScaelIf the value of the argument
5748351Scael.Fa c
5848351Scaelcharacter equals
5948351Scael.Dv EOF ,
6048351Scaelthe operation will fail and the stream will remain unchanged.
6148351Scael.Sh SEE ALSO
6248351Scael.Xr getc 3 ,
6348351Scael.Xr fseek 3 ,
6448351Scael.Xr setvbuf 3
6548351Scael.Sh STANDARDS
6648351ScaelThe
6748351Scael.Fn ungetc
6848351Scaelfunction conforms to
6948351Scael.St -ansiC .
70