| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 
 | #include <stdio.h>
#include <termios.h>
 
int l_getch ()
{
        static struct termios term, back;
        int ret=-1;
 
        tcgetattr (0, &term);   	/* On recupere les info du terminal */
        memcpy (&back, &term, sizeof(term));
 
        term.c_lflag &= ~(ICANON|ECHO);	/* On modifie les options du terminal */
        term.c_cc[VTIME] = 0;   	/* Temps d'attente infini */
        term.c_cc[VMIN]  = 1;   	/* Nombre minimun de caractere */
 
        tcsetattr(0, TCSANOW, &term);   /* Modif des attribut de stdin */
        ret = getchar();                /* Attente d'un caractere */
        tcsetattr(0, TCSANOW, &back);   /* Restauration des attributs */
 
        return ret;
}
 
int main(void)
{
 
        printf ("Appuyer sur une touche...\n\n");
        printf ("Vous avez appuyer sur la touche '%c'...\n\n", l_getch ());
        return 0;
} |