Home > Article > Backend Development > What is the function of putchar() in C language?
putchar() is a function in C language. Its function is: output a character to the terminal. The syntax structure is "int putchar(int char)", which can write the character specified by the parameter char (an unsigned character) to the standard output stdout.
putchar() is a function in C language. Its function is to output a character to the terminal.
The putchar() function is included in the C standard library ade979de5fc0e1ca0540f360a64c230b. The output can be a character, a decimal integer between 0 and 127 (including 0 and 127), or a character variable defined with char.
The syntax structure is:
int putchar(int char)
The character specified by the parameter char (an unsigned character) can be written to the standard output stdout.
Parameters:
char -- This is the character to be written. The character is passed with its corresponding int value.
Return value
This function returns the written character as an unsigned char cast to int, or EOF if an error occurs .
Example:
#include <stdio.h> int main () { char ch; for(ch = 'A' ; ch <= 'Z' ; ch++) { putchar(ch); } return(0); }
Output:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Recommended: "c Language Tutorial"
The above is the detailed content of What is the function of putchar() in C language?. For more information, please follow other related articles on the PHP Chinese website!