Home > Backend Development > C#.Net Tutorial > What is the function of putchar() in C language?

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

青灯夜游
Release: 2020-07-15 14:53:03
Original
7065 people have browsed it

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

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

Output:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
Copy after login

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!

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