putc [C++ Reference]
Keywords: c,io,putc
Date: 2008-10-14T15:42:01-0700

[[putc]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## putc

Syntax:

        #include <cstdio>
        int putc( int ch, FILE *stream );

The putc() function writes the character ch to stream. The return value is the character written, or EOF if there is an error. For example:

         int ch;
         FILE *input, *output;
         input = fopen( "tmp.c", "r" );
         output = fopen( "tmpCopy.c", "w" );
         ch = getc( input );
         while( ch != EOF ) {
           putc( ch, output );
           ch = getc( input );
         }
         fclose( input );
         fclose( output );

generates a copy of the file tmp.c called tmpCopy.c.

Related Topics: feof, fflush, fgetc, fputc, getc, getchar, putchar, puts

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •