putchar : <stdio.h> library function

The function int putchar(int character); writes a single character to the standard output stream(stdout). Calling putchar function is same as to calling putc with stdout as second argument.

Function prototype of putchar

int putchar(int character);
  • character : This is a character to be written on stdout(type casted to an integer).

Return value of putchar

This function returns the character written to stdout stream(type casted to an int value) otherwise returns EOF in case of an error.

C program to show the use of putchar function

The following program shows the use of putchar function to characters on standard output stream(stdout).

#include <stdio.h>
#include <string.h>

int main (){
   char c, *string = "putchar C Standard Library function";
   int counter, length = strlen(string);
   for(counter = 0 ; counter < length; counter++) {

Program Output
putchar C Standard Library function