Facebook Page Twitter Page LinkedIn Page
× C++ Standard Library C++ STL Library


The C++ <cstdio> 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 below example shows the usage of putchar() function.

#include <cstdio>
 
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++ <cstdio> Library

5