C library functions -putchar()

C Standard Library - <stdio.h>

Description

C Library Functionsint putchar(int char)Writes the character specified by the parameter char (an unsigned character) to standard output stdout.

Declaration

The following is the declaration of the putchar() function.

int putchar(int char)

Parameter

  • char-- This is the character to be written. The character is passed as its corresponding int value.

Return Value

This function returns the written character as an unsigned char cast to int, or returns EOF if an error occurs.

Example

The following example demonstrates the usage of the putchar() function.

#include <stdio.h>

int main ()
{
   char ch;

   for(ch = 'A' ; ch <= 'Z' ; ch++) {
      putchar(ch);
   }
   
   return(0);
}

Let us compile and run the above program, which will produce the following result:

ABCDEFGHIJKLMNOPQRSTUVWXYZ

C Standard Library - <stdio.h>

other extensions