Here's the format:
#include <stdio.h> int putchar(int c);
To make putchar() work, placing a literal character in the parentheses, as in
putchar('v');
Or you can place the ASCII code value (an integer) for the character in the parentheses.
The function returns the value of the character that's written.
#include <stdio.h> int main() /* w ww . j a v a 2s.c om*/ { int ch; printf("Press Enter: "); getchar(); ch = 'H'; putchar(ch); ch = 'i'; putchar(ch); putchar('!'); return(0); }
This code above uses the getchar() function to pause the program.
The statement getchar(); waits for input.
The input that's received isn't stored; it doesn't need to be.
Then the putchar() function displays the value of variable ch one character at a time.
Single-character values are assigned to the ch variable.