Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>getch() get a character from the console without echo</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 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 to the screen.  If a CONTROL-C (Ctrl-Break) is typed, the
    system executes an INT 23 and no character is returned.

       Returns:     The character read.  There is no error return.

          Note:     If the character returned is 0x00 or 0xE0. then a
                    function key or cursor positioning key has been
                    pressed, and another call is required to access the
                    actual key code.

   Portability:     MS-DOS only.

   -------------------------------- 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;
            }


See Also: cgets() getche() getchar()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson