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

NAME

12       getc - get a byte from a stream
13

SYNOPSIS

15       #include <stdio.h>
16
17       int getc(FILE *stream);
18
19

DESCRIPTION

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

RETURN VALUE

26       Refer to fgetc().
27

ERRORS

29       Refer to fgetc().
30
31       The following sections are informative.
32

EXAMPLES

34       None.
35

APPLICATION USAGE

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

RATIONALE

49       None.
50

FUTURE DIRECTIONS

52       None.
53

SEE ALSO

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