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

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

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