As we know that arrow keys produces two outputs 224
and 77
or 80
or 72
or 75
.
Code 1:-
int main()
{
int ch,ch1;
ch=getch();
ch1=getch();
printf("%d\n",ch);
printf("%d",ch1);
}
When you press up key
it displays
224
72
Code 2:-
int main()
{
char ch,ch1;
ch=getch();
ch1=getch();
printf("%d\n",ch);
printf("%d",ch1);
}
When you press up key
it displays
-32
72
My question is that, as you can see that the second output is same for both char
and int
, but why the first output i.e. 224
and -32
are different with int
and char
.