Created
          April 18, 2019 17:12 
        
      - 
      
 - 
        
Save mhashim6/7c21f8338f43a7e1ca36da4459661605 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
mhashim6 created this gist
Apr 18, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #include <fcntl.h> #include <signal.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/mman.h> #include <sys/termios.h> #include <sys/time.h> #include <sys/types.h> struct termios original_tio; void disable_input_buffering() { tcgetattr(STDIN_FILENO, &original_tio); struct termios new_tio = original_tio; new_tio.c_lflag &= ~ICANON & ~ECHO; tcsetattr(STDIN_FILENO, TCSANOW, &new_tio); } void restore_input_buffering() { tcsetattr(STDIN_FILENO, TCSANOW, &original_tio); } int main() { disable_input_buffering(); char c = getc(stdin); printf("%c\n", c); restore_input_buffering(); c = getc(stdin); printf("%c\n", c); }