putchar()

Write a character to stdout.

  #include <stdio.h>
    
   int putchar(int c);    
Parameter

c

The character to write to the stdout file.

Remarks

The putchar() function outputs c to stdout and advances the stream's file position indicator.

The putc() works identically to the fputc() function, except that it is written as a macro.

This function returns the character written when successful and returns EOF when it fails.

Listing: Example of putchar() Usage

#include <stdio.h>

#include <stdlib.h>

int main(void)

{

static char test[] = "flying fish and quail eggs\n";

int i;

/* Output the test character array. */

for (i = 0; test[i] > 0; i++)

{

if (putchar(test[i]) == EOF)

break;

}

return 0;

}

Output:

flying fish and quail eggs