getch() (z conio) ekvivalentne pre Linux/Unix

This entry was posted by piatok, 4 február, 2011
Read the rest of this entry »

Funkcia getch()
getch.h

#include <stdio.h>
#include <termios.h>
#include <unistd.h>
// getch() for Unix from http://cboard.cprogramming.com/faq-board/27714-faq-there-getch-conio-equivalent-linux-unix.html
int getch() {
struct termios oldt,
newt;
int            ch;
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
ch = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
return ch;
}

One Response to “getch() (z conio) ekvivalentne pre Linux/Unix”

  1. Fredy

    Parádny hlavičkový súbor veľmi pomohlo. :D


Leave a Reply