当前位置: 动力学知识库 > 问答 > 编程问答 >

c++ - Splitting up the output of _getchar()

问题描述:

I want to know when an arrow key is pressed. For that I've already found _getchar(). Unfortunately, that returns several values. It returns two different and separated values, even if I save it in one integer.

The first value is always 224, and the second one is the one I need. How can I get it, though?

I tried var[1], but that doesn't work, because it's an integer (didn't know one integer can hold several values).

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

}

Thanks :D

分享给朋友:
您可能感兴趣的文章:
随机阅读: