Currently At: Programming Reference > C Reference > Stndard C I/O > putc()

putc()


Syntax:
#include <stdio.h>
int putc( int ch, FILE *stream );


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

Example:
char 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 );

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


Related Topics:
fgetc(), fputc(), getchar(), putchar()


Web Standards & Support:

Link to and support eLook.org Powered by LoadedWeb Web Hosting
Valid XHTML 1.0! Valid CSS! eLook.org FireFox Extensions