[<<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()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson