Home > Backend Development > C#.Net Tutorial > Can the putchar function output a character to the terminal?

Can the putchar function output a character to the terminal?

王林
Release: 2020-07-03 10:00:49
Original
19313 people have browsed it

The putchar function can output a character to the terminal. The putchar function is a C library function that writes the characters specified by the char parameter to the standard output. The putchar function declaration: [int putchar(int char)], where the parameter char is the character to be written.

Can the putchar function output a character to the terminal?

The putchar function can output a character to the terminal. It is one of the C language functions.

(Recommended learning: C language tutorial)

Function introduction:

C library function int putchar(int char) puts the character specified by the parameter char (an unsigned character) is written to standard output stdout.

Function declaration:

int putchar(int char)
Copy after login

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.

Code example:

#include <stdio.h>
int main ()
{
   char ch;

   for(ch = &#39;A&#39; ; ch <= &#39;Z&#39; ; ch++) {
      putchar(ch);
   }
   
   return(0);
}
Copy after login

Result:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
Copy after login

The above is the detailed content of Can the putchar function output a character to the terminal?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template