Returns the next character from the standard input (stdin).
It is equivalent to calling getc with stdin as argument.
On success, the character read is returned (promoted to an int value).
The return type is int to accommodate for the special value EOF, which indicates failure:
If the standard input was at the end-of-file, the function returns EOF and sets the eof indicator (feof) of stdin.
If some other reading error happens, the function also returns EOF, but sets its error indicator (ferror) instead.
1 2 3 4 5 6 7 8 9 10 11 12 13
/* getchar example : typewriter */
int main ()
puts ("Enter text. Include a dot ('.') in a sentence to exit:");
} while (c != '.');
A simple typewriter. Every sentence is echoed once ENTER has been pressed until a dot (.) is included in the text.