fputc

write a character to an output stream

Synopsis:

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

Description:

The fputc() function writes the character specified by the argument c to the output stream designated by fp.

Returns:

The fputc() function returns the character written. If a write error occurs, the error indicator is set, and fputc() returns EOF. When an error has occurred, errno contains a value indicating the type of error that has been detected.

See also:

errno, fopen(), fputchar(), fputs(), putc(), putchar(), puts()

Examples:

#include <stdio.h>

void main()
  {
    FILE *fp;
    int c;

    fp = fopen( "file", "r" );
    if( fp != NULL ) {
      while( (c = fgetc( fp )) != EOF )
        fputc( c, stdout );
      fclose( fp );
    }
  }

Classification:

ANSI

Systems:

All (except DOS/PM)