Advertisement
Guest User

Untitled

a guest
Dec 26th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2. #include <termios.h>
  3. #include <unistd.h>
  4. using namespace std;
  5.  
  6. int mygetch(){
  7.     struct termios oldt,newt;
  8.     int ch;
  9.     tcgetattr( STDIN_FILENO, &oldt );
  10.     newt = oldt;
  11.     newt.c_lflag &= ~( ICANON | ECHO );
  12.     tcsetattr( STDIN_FILENO, TCSANOW, &newt );
  13.     ch = getchar();
  14.     tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
  15.     return ch;
  16. }
  17.  
  18. int main(){
  19.     int k = mygetch();
  20.     printf("%d\n",k);
  21.     if(k=='p')
  22.         puts("p");
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement