以下代码就可以:
//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
#include "conio.h"
int main(void){
int x;
while((x=getch())!=27)
printf("%d ",x);
printf("\n");
return 0;
}
#include
void main()
{
char c;
while(1)
{
c=getch();
if(c==27) {
break;
}
else
printf( "%c: %d\n", c, c );
}
}
#include
#include
int main()
{
int c;
while (27 != (c = getch()))
printf("%d\n", c);
return 0;
}