C Standard Library

C <stdio.h> - putchar() Function



The C <stdio.h> putchar() function writes a character to the output stream stdout. It is equivalent to calling putc() function with stdout as second argument.

Syntax

int putchar ( int ch );

Parameters

ch Specify a character to be written.

Return Value

On success, the character ch is returned. On failure, returns EOF and sets the error indicator ferror().

Example:

The example below shows the usage of putchar() function.

#include <stdio.h>
 
int main (){

  //prints character 
  for(char ch = 'A'; ch <= 'Z'; ch++)
    putchar(ch);
  
  return 0;
}

The output of the above code will be:

ABCDEFGHIJKLMNOPQRSTUVWXYZ

❮ C <stdio.h> Library