Skip to content

Commit a6ba919

Browse files
committed
opt judge method
1 parent ef71d25 commit a6ba919

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎c/getch/test/test.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ int main() {
77
char ch;
88
do {
99
ch = sh_getch();
10-
printf("You press \'%c\' \nAscii: %d\n\n", ch, ch);
11-
} while (ch != ESC);
12-
printf("You press \'%c\' \nAscii: %d\n\n", ch, ch);
13-
printf("ch:\'%c' \nExiting......", ch);
10+
if (ch > 31 && ch < 127) {
11+
printf("You press \'%c\' \nAscii: 0x%x\n\n", ch, ch);
12+
13+
} else {
14+
printf("Ascii: 0x%x", ch);
15+
printf("\n\n");
16+
}
17+
} while (ch != 'q');
18+
printf("ch:\'%c'\nExiting......", ch);
1419
}

‎c/getch/tools/getkeyvalue/getkeyvalue.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
int sh_getch(void);
44
int main() {
55
char ch;
6-
while ((ch = sh_getch()) != 0x1B) /* ESC to quit */
6+
while ((ch = sh_getch()) != 'q') /* q to quit */
77
{
88
printf("%d \n", ch);
99
}

0 commit comments

Comments
 (0)