Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>getche() get a character from console with echo</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
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;
         }

See Also: cgets() getch() getchar()

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