Name

fputc

Synopsis

Writes a character to a file

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

The fputc() function writes one character to the current file position of the specified FILE pointer. The return value is the character written, or EOF if an error occurred.

Example

#define CYCLES 10000
#define DOTS 4

printf("Performing %d modulo operations ", CYCLES );
for (int count = 0; count < CYCLES; ++count)
  {
    if ( count % ( CYCLES / DOTS ) != 0) continue;fputc( '.', stdout );            // Mark every nth cycle
  }
printf( " done.\n" );

This code produces the following output:

Performing 10000 modulo operations .... done.

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.