ggeettcc() -- STDIO Function (libc)

Read character from file stream
#iinncclluuddee <ssttddiioo.hh>
iinntt ggeettcc(_f_p)
FFIILLEE *_f_p;

ggeettcc() is  a function that reads  a character from the  file stream _f_p, and
returns an iinntt.

_E_x_a_m_p_l_e
The following  example creates a  simple copy utility.  It  opens the first
file named on the command line and copies its contents into the second file
named on the command line.

#include <stdio.h>

void fatal(string)
char *string;
{
    printf("%s\n", string);
    exit (1);
}

main(argc, argv)
int argc; char *argv[];
{
    int foo;
    FILE *source, *dest;

    if (--argc != 2)
        fatal("Usage: copy [source][destination]");

    if ((source = fopen(argv[1], "r")) == NULL)
        fatal("Cannot open source file");
    if ((dest = fopen(argv[2], "w")) == NULL)
        fatal("Cannot open destination file");

    while ((foo = getc(source)) != EOF)
        putc(foo, dest);
}

_S_e_e _A_l_s_o
ffggeettcc(), ggeettcchhaarr(), lliibbcc, ppuuttcc()
ANSI Standard, section 7.9.7.5
POSIX Standard, section 8.1

_D_i_a_g_n_o_s_t_i_c_s
ggeettcc() returns EOF at end of file or on read fatal.

_N_o_t_e_s
Because ggeettcc()  is a macro,  arguments with side effects  probably will not
work as  expected.  Also,  because ggeettcc()  is a complex  macro, its  use in
expressions of  too great a  complexity may cause  unforeseen difficulties.
Use of the function ffggeettcc() may avoid this.
