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

NAME

6       getc - get a byte from a stream
7

SYNOPSIS

9       #include <stdio.h>
10
11       int getc(FILE *stream);
12
13

DESCRIPTION

15       The  getc() function shall be equivalent to fgetc() , except that if it
16       is implemented as a macro it may evaluate stream more than once, so the
17       argument should never be an expression with side effects.
18

RETURN VALUE

20       Refer to fgetc() .
21

ERRORS

23       Refer to fgetc() .
24
25       The following sections are informative.
26

EXAMPLES

28       None.
29

APPLICATION USAGE

31       If  the  integer  value returned by getc() is stored into a variable of
32       type char and then compared against the integer constant EOF, the  com‐
33       parison may never succeed, because sign-extension of a variable of type
34       char on widening to integer is implementation-defined.
35
36       Since it may be implemented as a macro, getc() may treat incorrectly  a
37       stream  argument  with side effects. In particular, getc(*f++) does not
38       necessarily work as expected.  Therefore, use of this  function  should
39       be  preceded by "#undef getc" in such situations; fgetc() could also be
40       used.
41

RATIONALE

43       None.
44

FUTURE DIRECTIONS

46       None.
47

SEE ALSO

49       fgetc()  ,  the  Base  Definitions  volume   of   IEEE Std 1003.1-2001,
50       <stdio.h>
51
53       Portions  of  this text are reprinted and reproduced in electronic form
54       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
55       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
56       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
57       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
58       event of any discrepancy between this version and the original IEEE and
59       The  Open Group Standard, the original IEEE and The Open Group Standard
60       is the referee document. The original Standard can be  obtained  online
61       at http://www.opengroup.org/unix/online.html .
62
63
64
65IEEE/The Open Group                  2003                              GETC(P)
Impressum