Use putchar function to output character to standard output

Syntax

C putchar function has the following syntax.

int putchar(int ch);

C putchar function is from header file stdio.h.

Description

C putchar function outputs character to stdout.

C putchar function returns the character written if successful or EOF on error.

Example

Write character to standard output using C putchar function.


#include <stdio.h>
int main(void){
// w ww  . j  av  a  2s. c  o m
   char *str = "www.java2s.com";

   for(; *str; str++){
       putchar(*str);
   }
}

The code above generates the following result.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h