Home  >  Article  >  Backend Development  >  Can the putchar function output a character to the terminal?

Can the putchar function output a character to the terminal?

王林
王林Original
2020-07-03 10:00:4919229browse

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)

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);
}

Result:

ABCDEFGHIJKLMNOPQRSTUVWXYZ

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!

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