0

I was trying to find the character code for arrow keys so wrote this-

char x=_getch();
cout<<(int)x;  

No matter which arrow key I pressed it printed -32. Then I added one line and my code looked like this-

char x=_getch();
x=_getch();
cout<<(int)x;  

With the above code it was printing correct values. Can anyone explain why this is happening.
I am using Code::Blocks with GNU GCC Compiler.

ShadowRanger
  • 124,179
  • 11
  • 158
  • 228
TubbyStubby
  • 108
  • 2
  • 11

1 Answers1

0

I think this will answer your question enter image description here

A similar question has been answered at the following link.

getch and arrow codes

This is the screenshot from one of the answer's from that link

Saboor Elahi
  • 332
  • 3
  • 6