C Library Function - putchar()
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
- char -- This is the character to be written. The character is passed as its corresponding int value.
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 -