When I try print getk function direct with printf. It working fine. But when I store it to variable then always output is same. I am trying to get arrow keys as a input
I am using gcc on code block windows 7.
int getk()
{
int ch;
ch = getch();
if (ch == 0)
{
ch = getch();
return ch;
}
return ch;
}
void main()
{
int a, b;
a = getk();
printf("%d %d", a, getk());
}
I expect same output in both cases in printf because getk return type and variable a data type are same then why output is diffrent