411 REFERENCE · Wikibooks
C++ Programming/Code/Standard C Library/Functions/putc
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
putc
#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