Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <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 without echoing it
    to the screen.  If the character read is CONTROL-C (Ctrl-Break), an
    INT 23 is executed, and the character is not returned.

    Returns:    The character read; no error return.

       Note:    If the character returned is 00h or E0h, then a function
                key or cursor-positioning key has been pressed, and
                another call is requred to access the actual key code.

 Portability:   Applies to 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