DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Termios

02.09.2006
| 184 views |
  • submit to reddit
        // description of your code here

#include <termios.h>
#include <unistd.h>
#include <stdio.h>

int main() {
   struct termios orig, changes;

   tcgetattr(STDIN_FILENO, &orig);

   changes = orig;
   changes.c_lflag &= ~(ICANON|ECHO);
   tcsetattr(STDIN_FILENO, TCSADRAIN, &changes);

   puts("Hit any key!");
   getchar();
   puts("Thanks!");

   /* restore old settings */
   tcsetattr(STDIN_FILENO, TCSADRAIN, &orig);
   return 0;
}

    
    Tags:
  • C