Retourner au contenu associé (entrée de forum : récupération d'un caractère)
Posté par JJD le 19 octobre 2004 à 15:10. En réponse au message récupération d'un caractère. Évalué à 3.
#include <stdlib.h> #include <stdio.h> #include <termios.h> #include <unistd.h> int main(void) { int c; struct termios *termios_p; termios_p=(struct termios *)malloc(sizeof(struct termios)); tcflag_t lflag; // Récupération des attributs du terminal tcgetattr(0,termios_p); // Sauvegarde des attributs lflag=termios_p->c_lflag; // Modification termios_p->c_lflag &= ~(ECHO); tcsetattr(0,TCSANOW,termios_p); c=getc(stdin); printf("Pas d'echo du caractère tapé...\n"); printf("caractère : %c ; code ASCII : %u 0X%X\n",c,c,c); // Rétablissement des attributs d'origine termios_p->c_lflag=lflag; tcsetattr(0,TCSANOW,termios_p); return 0; }
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
# Petit exemple en C
Posté par JJD . En réponse au message récupération d'un caractère. Évalué à 3.
#include <stdlib.h> #include <stdio.h> #include <termios.h> #include <unistd.h> int main(void) { int c; struct termios *termios_p; termios_p=(struct termios *)malloc(sizeof(struct termios)); tcflag_t lflag; // Récupération des attributs du terminal tcgetattr(0,termios_p); // Sauvegarde des attributs lflag=termios_p->c_lflag; // Modification termios_p->c_lflag &= ~(ECHO); tcsetattr(0,TCSANOW,termios_p); c=getc(stdin); printf("Pas d'echo du caractère tapé...\n"); printf("caractère : %c ; code ASCII : %u 0X%X\n",c,c,c); // Rétablissement des attributs d'origine termios_p->c_lflag=lflag; tcsetattr(0,TCSANOW,termios_p); return 0; }