getchar
int  getchar ( void );
stdio.h
  cplusplus.com  

Get the next character from stdin.
  Returns the next character from the standard input (stdin).
  It corresponds to: getc(stdin)

Parameters.

(none)
 

Return Value.
  The character read is returned as int. If the End Of File is reached or there has been an error reading, the function returns an EOF character.
  EOF can also indicate an error while reading, use ferror() to check if an error has occurred.
 

Portability.
  Defined in ANSI-C.

Example.

/* getchar example : typewriter */
#include <stdio.h>

main ()
{
  char c;
  puts ("Enter text. Include a dot ('.') in a sentence to exit:");
  do {
    c=getchar();
    putchar (c);
  } while (c != '.');
  return 0;
}
  A simple typewriter. Every sentence is echoed once ENTER has been pressed until a dot (.) is included in the text.

See also.
  getc, putchar, fgetc, fopen


© The C++ Resources Network, 2000