putchar() Library Function with Examples

The putchar() function is used for printing character to a screen at current cursor location. It is unformatted character output functions. It is defined in header file stdio.h.

putchar() Syntax


putchar() Examples

Example #1 : Displaying Character Using putchar()


void main()
  char ch;
  clrscr(); /* Clear the screen */
  printf(β€œPress any character: ”);
  ch = getche();
  printf(β€œ\nPressed character is:”);
  getch(); /* Holding output */

Output of the above program :

Press any character: f
Pressed character is: f

Note: while using getche() pressed character 
is also echoed. Here pressed character is f 
and it is displayed by putchar() later.