Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C Library Function - putchar()

C Library Function - putchar()

C Standard Library - <stdio.h> C Standard Library -

Description

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

Declaration

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



int putchar(int char)

Parameters

Return Value

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

Example

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



#include 



int main ()

{

   char ch;



   for(ch = 'A' ; ch <= 'Z' ; ch++) {

      putchar(ch);

   }

   

   return(0);

}

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



ABCDEFGHIJKLMNOPQRSTUVWXYZ

C Standard Library - <stdio.h> C Standard Library -