Home Common Problem What is the function of putchar()

What is the function of putchar()

Jan 07, 2021 am 11:14 AM
putchar

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 .

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)
Copy after login

(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);
}
Copy after login

Let us compile and run the above program, which will produce the following results:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
Copy after login

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 of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)