Compare putchar function with the getchar function.
The following program uses getchar to copy the first word from a line of input entered at the terminal's keyboard. Then, it displays the word on the terminal's screen.
#include
int c;
main()
{
puts("Enter some words on a line.");
/* Look for white space */
while ((c != ' ') && (c != '\t') && (c != '\n'))
{
c = getchar();
putchar(c);
}
putchar('\n');
}