arrows

i want to make a program such that if i press the down arrow key , my name is displayed .

so how do i get input from the user as the down arrow key??

please help !!
Last edited on
...
Last edited on
First of all, what OS and compiler are you using?
c++ compiler

windows operating system
I think the shorter way would be something like this:
while(true) cout << (GetAsyncKeyState(VK_DOWN)||GetAsyncKeyState(VK_UP)?"hello!":" ") << "\b\b\b\b\b\b";

(windows.h required)
GetAsyncKeyState returns 0 if the given key is up, non-zero when it is down

VK_DOWN, VK_UP are maros for key

"\b\b\b\b\b\b" puts the cursor back (each '\b' is a step)
For this you should better use SetConsoleCursorPosition
Last edited on
im using c++ compiler not c compiler
please help someone
please help someone
Bazzy's code works on a MinGW Compiler..
I think my code would work on any c++ compiler for windows
Last edited on
Topic archived. No new replies allowed.