拆分_getchar()的输出

时间:2016-02-20 15:29:12

标签: c++ integer getchar conio

我想知道何时按下箭头键。为此,我已经找到了_getchar()。不幸的是,这会返回几个值。它返回两个不同且分隔的值,即使我将其保存在一个整数中。

第一个值总是224,第二个值是我需要的值。但是我怎么能得到它呢?

我尝试var[1],但这不起作用,因为它是一个整数(不知道一个整数可以包含多个值)

int posX = 5;
int posY = 10;

while(1)
{

    switch(_getch())
    {
        case 72:
            posY++;
        case 80:
            posY--;
        case 75:
            posX--;
        case 77:
            posX++;
    }

    build(posX, posY); // a function to visualize things, not necessary for my problem
}

谢谢:D

0 个答案:

没有答案