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>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 to
    the current text window.  If a CONTROL-C (Ctrl-Break) is entered, the
    system executes an INT 23, and the character is not 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 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