getch() Get a Character from the Console without Echo
#include <conio.h> Required for declarations only
int getch(void);
getch() reads a single character from the console; the character is
not echoed. If a CONTROL-C (Ctrl-Break) is typed, the system
executes an INT 23.
Returns: The character read. There is no error return.
-------------------------------- Example ---------------------------------
The following statements prompt for a word and store it as a string
for future use. The typed characters are not echoed to the screen.
#include <conio.h>
#include <stdio.h> /* for printf */
#include <ctype.h> /* for isalpha */
int ch;
char password[8];
main()
{
int x= 0;
printf("ENTER YOUR PASSWORD: ");
while (isalpha(ch = getch()))
password[x++] = ch;
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster