我所限定的四個箭頭鍵作爲such-檢測爲雙方向上和向右C++,向上箭頭
#define UP_ARROW 72
#define LEFT_ARROW 75
#define DOWN_ARROW 80
#define RIGHT_ARROW 77
並且鍵正在使用_getch()檢查,因爲這樣的
char key = _getch();
if (key == 0 || key == -32)
{
key = _getch();
switch (key)
{
case UP_ARROW:
//These are functions not relevant to the problem
//up(1);
case DOWN_ARROW:
//down(1);
case LEFT_ARROW:
//left(1);
case RIGHT_ARROW:
//right(1);
//Pressing up will print out "test", which should not happen
printf("test");
}
}
作爲評論說,按下會在RIGHT_ARROW情況下調用任何東西。我做錯什麼了嗎?