Receive character in C

0

How do I make a function in C that is equal to the function Readkey of Pascal or equal to function Lastkey of old Clipper ? I want to receive only one character for each key pressed. Create menus, receive ESC key, etc. Thanks in advance.

    
asked by anonymous 13.01.2016 / 21:12

1 answer

0

In C you need an external library to do this. The language pattern does not define a way for this. An external library that exhibits this functionality is ncurses ; there must be others, but I do not know.

Example taken from NCURSES Programming HOWTO and with some changes to my liking :

#include <ncurses.h>

int main(void) {    
    initscr();                /* Start curses mode              */
    printw("Hello, World!");  /* Print Hello. World!            */
    refresh();                /* Print it on to the real screen */
    getch();                  /* Wait for user input            */
    endwin();                 /* End curses mode                */
    return 0;
}
    
14.01.2016 / 11:32