Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ () — Coherent 3.1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought


fputc()                       STDIO                       fputc()




Write character into file stream

#include <stdio.h>
int fputc(c, fp) char c; FILE *fp;

fputc writes  the character c into the file  stream pointed to by
fp.  It returns c if c was written successfully.

***** Example *****

The following  example uses  fputc 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");






COHERENT Lexicon                                           Page 1



fputc()                       STDIO                       fputc()



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


***** See Also *****

STDIO

***** Diagnostics *****

fputc returns  EOF when a  write error occurs, e.g.,  when a disk
runs out of space.












































COHERENT Lexicon                                           Page 2


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026