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>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 and echoes a character from the console.  If the
    character 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 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