The function of putchar() is to output a character to the terminal; the syntax structure of putchar is "int putchar(int char)", which means writing the character specified by the parameter char to the standard output stdout; putchar is C Library functions, included in the C standard library
.
The operating environment of this article: Windows 7 system, Dell G3 computer, C11 version.
The syntax structure of putchar() is int putchar(int char). Its function is to write the character specified by the parameter char (an unsigned character) to the standard output stdout. It is a C library function and is included in C Standard library
The output can be a character, a decimal integer between 0 and 127 (including 0 and 127), or a character variable defined with char .
putchar syntax
(1) Function declaration
int putchar(int char)
(2) Parameter
char--This is the character to be written. The character is passed with its corresponding int value.
(3) Function
Write the character specified by parameter char (an unsigned character) to the standard output stdout. [3]
(4) Description
This function outputs the characters corresponding to the value of the specified expression to the standard output terminal. The expression can be a character type or an integer type, and it can only output one character at a time. For example: "putchar('#')" outputs the character "#".
Return value
This function returns the written character as an unsigned char cast to int, or EOF if an error occurs.
Example
The following example demonstrates the use 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 results:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Recommended: "c Video Tutorial"
The above is the detailed content of What is the function of putchar(). For more information, please follow other related articles on the PHP Chinese website!