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

NAME

12       ungetc — push byte back into input stream
13

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

59       None.
60

APPLICATION USAGE

62       None.
63

RATIONALE

65       None.
66

FUTURE DIRECTIONS

68       None.
69

SEE ALSO

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