• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

programming question

Kntx

Platinum Member
I'm programming something in C and I want the arrow keys on the keyboard to affect a variable.

How do I go about doing that???

 
My C skills are rusty, but I would try something like this to determine which ASCII character the arrow keys represent:

char c;

while (true) {
c = getchar();
println("You just pressed: %c.", c);
println("That is ascii: %d.", c);
}

Then, once you know what value the arrow keys return, you could do whatever you want when they are pressed. For example, if the up-arrow returned 201 (I don't know what it really returns):

while (true) {
c = charchar();
if (c == 201) {
variable++;
}
if (c == 'Q') {
// Quit
break;
}
}

 
Back
Top