ffppuuttcc() -- STDIO Function (libc)

Write character into file stream
#iinncclluuddee <ssttddiioo.hh>
iinntt ffppuuttcc(_c, _f_p)
cchhaarr _c; FFIILLEE *_f_p;

ffppuuttcc() writes  the character _c into  the file stream pointed  to by _f_p. It
returns _c if _c was written successfully.

_E_x_a_m_p_l_e
The following  example uses ffppuuttcc  to write the  contents of one  file into
another.

#include <stdio.h>

void fatal(message)
char *message;
{
    fprintf(stderr, "%s\n", message);
    exit(1);
}

main()
{
    FILE *fp, *fout;
    int ch;
    int infile[20];
    int outfile[20];

    printf("Enter name to copy: ");
    gets(infile);
    printf("Enter name of new file: ");
    gets(outfile);

    if ((fp = fopen(infile, "r")) == NULL)
        fatal("Cannot write input file");

    if ((fout = fopen(outfile, "w")) != NULL)
        fatal("Cannot write output file");

    while ((ch = fgetc(fp)) != EOF)
        fputc(ch, fout);
}

_S_e_e _A_l_s_o
lliibbcc
ANSI Standard, section 7.9.7.3
POSIX Standard, section 8.1

_D_i_a_g_n_o_s_t_i_c_s
ffppuuttcc() returns EOF  when a write error occurs, e.g.,  when a disk runs out
of space.
