1GETC(3P)                   POSIX Programmer's Manual                  GETC(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       getc — get a byte from a stream
14

SYNOPSIS

16       #include <stdio.h>
17
18       int getc(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  getc()  function shall be equivalent to fgetc(), except that if it
27       is implemented as a macro it may evaluate stream more than once, so the
28       argument should never be an expression with side-effects.
29

RETURN VALUE

31       Refer to fgetc().
32

ERRORS

34       Refer to fgetc().
35
36       The following sections are informative.
37

EXAMPLES

39       None.
40

APPLICATION USAGE

42       If  the  integer  value returned by getc() is stored into a variable of
43       type char and then compared against the integer constant EOF, the  com‐
44       parison may never succeed, because sign-extension of a variable of type
45       char on widening to integer is implementation-defined.
46
47       Since it may be implemented as a macro, getc() may treat incorrectly  a
48       stream  argument  with side-effects. In particular, getc(*f++) does not
49       necessarily work as expected. Therefore, use of this function should be
50       preceded  by  "#undefgetc"  in  such  situations; fgetc() could also be
51       used.
52

RATIONALE

54       None.
55

FUTURE DIRECTIONS

57       None.
58

SEE ALSO

60       Section 2.5, Standard I/O Streams, fgetc()
61
62       The Base Definitions volume of POSIX.1‐2008, <stdio.h>
63
65       Portions of this text are reprinted and reproduced in  electronic  form
66       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
67       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
68       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
69       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
70       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
71       event of any discrepancy between this version and the original IEEE and
72       The  Open Group Standard, the original IEEE and The Open Group Standard
73       is the referee document. The original Standard can be  obtained  online
74       at http://www.unix.org/online.html .
75
76       Any  typographical  or  formatting  errors that appear in this page are
77       most likely to have been introduced during the conversion of the source
78       files  to  man page format. To report such errors, see https://www.ker
79       nel.org/doc/man-pages/reporting_bugs.html .
80
81
82
83IEEE/The Open Group                  2013                             GETC(3P)
Impressum