1UNGETC(3P)                 POSIX Programmer's Manual                UNGETC(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       ungetc — push byte back into input stream
14

SYNOPSIS

16       #include <stdio.h>
17
18       int ungetc(int c, FILE *stream);
19

DESCRIPTION

21       The functionality described on this reference page is aligned with  the
22       ISO C  standard.  Any  conflict between the requirements described here
23       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2008
24       defers to the ISO C standard.
25
26       The  ungetc() function shall push the byte specified by c (converted to
27       an unsigned char) back onto the input stream pointed to by stream.  The
28       pushed-back  bytes shall be returned by subsequent reads on that stream
29       in the reverse order of their pushing. A  successful  intervening  call
30       (with  the  stream pointed to by stream) to a file-positioning function
31       (fseek(), fseeko(), fsetpos(), or rewind()) or fflush()  shall  discard
32       any  pushed-back bytes for the stream. The external storage correspond‐
33       ing to the stream shall be unchanged.
34
35       One byte of push-back shall be provided. If ungetc() is called too many
36       times  on the same stream without an intervening read or file-position‐
37       ing operation on that stream, the operation may fail.
38
39       If the value of c equals that of the macro  EOF,  the  operation  shall
40       fail and the input stream shall be left unchanged.
41
42       A successful call to ungetc() shall clear the end-of-file indicator for
43       the stream. The value of the file-position  indicator  for  the  stream
44       after  all  pushed-back  bytes  have been read, or discarded by calling
45       fseek(), fseeko(), fsetpos(), or rewind() (but not fflush()), shall  be
46       the same as it was before the bytes were pushed back. The file-position
47       indicator is decremented by each successful call to  ungetc();  if  its
48       value was 0 before a call, its value is unspecified after the call.
49

RETURN VALUE

51       Upon  successful completion, ungetc() shall return the byte pushed back
52       after conversion. Otherwise, it shall return EOF.
53

ERRORS

55       No errors are defined.
56
57       The following sections are informative.
58

EXAMPLES

60       None.
61

APPLICATION USAGE

63       None.
64

RATIONALE

66       None.
67

FUTURE DIRECTIONS

69       None.
70

SEE ALSO

72       Section 2.5, Standard I/O Streams, fseek(), getc(), fsetpos(),  read(),
73       rewind(), setbuf()
74
75       The Base Definitions volume of POSIX.1‐2008, <stdio.h>
76
78       Portions  of  this text are reprinted and reproduced in electronic form
79       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
80       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
81       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
82       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
83       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
84       event of any discrepancy between this version and the original IEEE and
85       The Open Group Standard, the original IEEE and The Open Group  Standard
86       is  the  referee document. The original Standard can be obtained online
87       at http://www.unix.org/online.html .
88
89       Any typographical or formatting errors that appear  in  this  page  are
90       most likely to have been introduced during the conversion of the source
91       files to man page format. To report such errors,  see  https://www.ker
92       nel.org/doc/man-pages/reporting_bugs.html .
93
94
95
96IEEE/The Open Group                  2013                           UNGETC(3P)
Impressum