![]() |
![]() |
![]() |
Write a character to stdout
#include <stdio.h> int fputchar( int c );
libc
The fputchar() function writes the character specified by c, cast as (int)(unsigned char), to stdout. It's equivalent to putchar() and to:
fputc( c, stdout );
The character written, cast as (int)(unsigned char), or EOF if an error occurred (errno is set).
#include <stdio.h> #include <stdlib.h> int main( void ) { FILE *fp; int c; fp = fopen( "file", "r" ); if( fp != NULL ) { c = fgetc( fp ); while( c != EOF ) { fputchar( c ); c = fgetc( fp ); } fclose( fp ); return EXIT_SUCCESS; } return EXIT_FAILURE; }
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
If c is negative, the value returned by this function isn't equal to c -- unless c is -1 and an error occurred :-)
errno, fprintf(), fputc(), fputs(), putc(), putchar()
![]() |
![]() |
![]() |