Skip to content

Instantly share code, notes, and snippets.

@sakti
Created December 21, 2010 11:32
Show Gist options
  • Save sakti/749824 to your computer and use it in GitHub Desktop.
Save sakti/749824 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
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;
}
int main(){
char a=getch();
printf("karakter input = %c\n",a);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment