[Previous]
[Contents]
[Next]

putc()

write a character to an output stream

Synopsis:

#include <stdio.h>

int putc( int c, FILE *fp );

Description:

The putc() function is equivalent to fputc(), except it may be implemented as a macro. The putc() function writes the character specified by the argument c to the output stream designated by fp.

Returns:

The character written. If a write error occurs, errno is set and putc() returns EOF.

Examples:

#include <stdio.h>

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

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

Classification:

ANSI

Safety:
Interrupt handler No
Signal handler No
Thread Yes

Caveats:

putc() may be implemented as a macro.

See also:

errno, ferror(), fopen(), fputc(), fputchar(), fputs(), putchar(), puts()


[Previous]
[Contents]
[Next]