Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

putchar() function in C

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The putchar(int char) method in C is used to write a character, of unsigned char type, to stdout. This character is passed as the parameter to this method.

Syntax:

int putchar(int char)

Parameters: This method accepts a mandatory parameter char which is the character to be written to stdout.

Return Value: This function returns the character written on the stdout as an unsigned char. It also returns EOF when some error occurs.

Below examples illustrate the use of putchar() method:

Example 1:




// C program to demonstrate putchar() method
  
#include <stdio.h>
  
int main()
{
  
    // Get the character to be written
    char ch = 'G';
  
    // Write the Character to stdout
    putchar(ch);
  
    return (0);
}

Output:

G

Example 2:




// C program to demonstrate putchar() method
  
#include <stdio.h>
  
int main()
{
  
    // Get the character to be written
    char ch = '1';
  
    // Write the Character to stdout
    for (ch = '1'; ch <= '9'; ch++)
        putchar(ch);
  
    return (0);
}

Output:

123456789

My Personal Notes arrow_drop_up
Last Updated : 10 Jan, 2019
Like Article
Save Article
Similar Reads