Latest web development tutorials

C library functions - putchar ()

C standard library - <stdio.h> C standard library - <stdio.h>

description

C library functionsint putchar (int char) char the parameters specified character (an unsigned character) is written to standard output stdout.

statement

Here is () statement putchar function.

int putchar(int char)

parameter

  • char - which it is to be written character.The character of its corresponding int value passed.

return value

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

Examples

The following example demonstrates the putchar () function is used.

#include <stdio.h>

int main ()
{
   char ch;

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

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

ABCDEFGHIJKLMNOPQRSTUVWXYZ

C standard library - <stdio.h> C standard library - <stdio.h>