Home  >  Article  >  Backend Development  >  What is the function of putchar() in C language?

What is the function of putchar() in C language?

青灯夜游
青灯夜游Original
2020-07-15 14:46:566949browse

putchar() is a function in C language. Its function is: output a character to the terminal. The syntax structure is "int putchar(int char)", which can write the character specified by the parameter char (an unsigned character) to the standard output stdout.

What is the function of putchar() in C language?

putchar() is a function in C language. Its function is to output a character to the terminal.

The putchar() function is included in the 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.

The syntax structure is:

int putchar(int char)

The character specified by the parameter char (an unsigned character) can be written to the standard output stdout.

Parameters:

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

Example:

#include <stdio.h>

int main ()
{
   char ch;

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

Output:

ABCDEFGHIJKLMNOPQRSTUVWXYZ

Recommended: "c Language Tutorial"

The above is the detailed content of What is the function of putchar() in C language?. 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