C examples for stdio.h:getchar
function
<cstdio> <stdio.h>
Returns the next character from the standard input (stdin).
It is equivalent to calling getc with stdin as argument.
int getchar ( void );
none
On success, the character read is returned.
The following code prints all characters read from keyboard.
#include <stdio.h> int main ()// w w w. j a v a 2s .co m { int c; puts ("Enter text. Include a dot ('.') in a sentence to exit:"); do { c=getchar(); putchar (c); } while (c != '.'); return 0; }