getche() Get a Character from Console with Echo
#include <conio.h> Required for declarations only
int getche(void);
getche() reads a single character from the console and echoes it. If
a CONTROL-C (Ctrl-Break) is entered, the system executes an INT 23.
Returns: The character read. There is no error return.
-------------------------------- Example ---------------------------------
The following statements print a prompt, get characters from the
console, and store them in a buffer. The characters are echoed to the
screen as they are typed.
#include <conio.h>
#include <ctype.h>
#include <stdio.h>
int ch;
int x = 0;
char buffer[35];
main()
{
printf("Enter your name: ");
while(isalpha(ch = getche()))
buffer[x++] = ch;
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster