#include <QtCore/QCoreApplication>#include <stdio.h>#include <stdlib.h>int main(int argc, char *argv[]){int code = 0;while (code !=10) {code = getchar();printf("%d\n", code);}return EXIT_SUCCESS;}
#include <QtCore/QCoreApplication>#include <stdio.h>#include <stdlib.h>#include <conio.h>#define ESC 27int main(int argc, char *argv[]){int c;while (c != ESC) {c = getch();printf("Key \"%c\" = Code \"%d\"\n", c, (int)c);}return EXIT_SUCCESS;}
#include <stdio.h>#ifndef __linux#include <conio.h>#else#include <unistd.h>#include <termios.h>int getch(){ int ch; struct termios oldt, newt; tcgetattr( STDIN_FILENO, &oldt ); newt = oldt; newt.c_lflag &= ~( ICANON | ECHO ); tcsetattr( STDIN_FILENO, TCSANOW, &newt ); ch = getchar(); tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); return ch;}#endifint main(int argc, char *argv[]){ char ch; while (ch !=27) { ch = getch(); printf("Key %c code %d\n", ch, ch); } return 0;}
Key v code 118Key j code 106 // буржуинская букваKey � code -48Key � code -71 // а на рускую "й" две строки
Key a code 97Key b code 98Key c code 99Key й code -54Key ё code -93Key а code -63Key б code -62Key в code -41
......int main(int argc, char *argv[]){ int ch; // <--- вот эту строку while (ch !=27) { ch = getch(); printf("Key %c code %d\n", ch, ch); } return 0;}
printf("Key %c code %d\n", ch, ch);
qDebug() << "Key " << QChar::fromAscii( (char)ch ) << " code " << ch;