我正在制作一个小C程序,要求输入密钥并在switch语句中执行一些代码.
#include <stdio.h>
#include <conio.h>
int main(int argc, char const *argv[]){
/* code */
printf("Hello, press a, b or c to continue");
char key = getch();
switch (key){
case 'a':
clrscr();
//some code
break;
case 'b':
//many lines of code
break;
case 'c':
clrscr();
//many lines of code
break;
default:
printf("Ok saliendo\n");
break;
}
printf("bye");
}
Run Code Online (Sandbox Code Playgroud)
getch()工作正常,但clrscr()不是,即使我包括在内<conio.h>.
为什么?