How would I compare a char to see if it was up, down, left, or right?

(I originally posted this on the Beginners board, but wasn't getting any replies there, so this is a repost)

Say I use getch(), and the person enters the up, down, left, or right key. How would I compare the variable (Let's say the variable is called 'Var') to see if it was one of those keys in an if statement?
http://www.cplusplus.com/forum/articles/28558/

and then if you really want to..
http://msdn.microsoft.com/en-us/library/078sfkak(v=vs.80).aspx
http://msdn.microsoft.com/en-us/library/ms927178.aspx

though you could just compile
1
2
int c = getch();
std::cout << c;
and see for yourself.
I had already tried the cout test, and it would just give an identical unicode-looking character for each one. I'll check out the sites though, thanks!
And yeah, I understand it's terrible for games. It's just that I was working on this a while back, and rediscovering it, really wanted to complete it. Also, I have a problem still. Comparing as

if(Var == 56){}

doesn't work, and neither does VK_UP. I think I am just being extremely ignorant.
http://www.cplusplus.com/forum/beginner/36410/#msg196998
conio? I though it was ncurses, sorry.

I had already tried the cout test, and it would just give an identical unicode-looking character for each one
cast it to int.
0x26 = .38

Edit:
doesn't work, and neither does VK_UP
weird. Check if there is an equivalent to keypad or something that needs to be configured.
Post the code, and please be patient

Edit2: from the hamsterman's link:
When reading a function key or an arrow key, each function must be called twice; the first call returns 0 or 0xE0, and the second call returns the actual key code.
Last edited on
Topic archived. No new replies allowed.