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
  • 143,180
  • 12
  • 188
  • 271
TubbyStubby
  • 137
  • 3
  • 13

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
  • 352
  • 3
  • 8