."/> .">

Home  >  Article  >  What is the function of putchar()

What is the function of putchar()

藏色散人
藏色散人Original
2021-01-07 11:14:4419957browse

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.

What is the function of putchar()

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 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 .

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 = &#39;A&#39; ; ch <= &#39;Z&#39; ; 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn