如何用bioskey实现esc退出循环~~晕了晕了
在网上看了好几天也没搞明白到底怎么做
像下面这段程序,我想实现按esc退出循环,否则给数组附值,编译通过,但是运行的时候和想象中的不一样,哪出错了呢?
#include "stdio.h "
#include "bios.h "
void main()
{
int i,a[10];
int key=bioskey(0);
clrscr();
for(i=0;i <10;i++)
{if(key&27==27) break;
else scanf( "%d ",&a[i]);}
}
[解决办法]
#include "stdio.h "
#include "conio.h "
main()
{
while(1)
{
if(kbhit())
{
if(bioskey(0)==283)
{
printf( "Inkey:ESC ");
break;
}
}
}
getch();
}
[解决办法]
tc3.0 通过运行,不知道符合你的要求不?
#include "stdio.h "
#include "bios.h "
#include "stdlib.h "
void main()
{
int i,a[10];
int key;
clrscr();
for(i=0;i <10;i++)
{
printf( "input the ESC to quit,or enter any other key\n ");
fflush(stdin);
key=bioskey(0)&0xff;
printf( "%d ",key);
if((key&27)==27)
break;
else
{
printf( "please input a[%d]\n ",i);
scanf( "%d ",&a[i]);
}
}