![]() |
|
#1
|
||||
|
||||
Receive arrow key inputhow to receive arrow key : up,down,left,right input
for e.g. char input; if ( input == up ) // mean up arrow key cout<< " up arrow key "; thx __________________
challenges are make life interesting, overcome them is make life meaningful. |
|
#2
|
|||
|
|||
|
For what version of what operating system would you like to do this? Also, are you already using a framework/library (such as MFC) that has it's very own custom way of dealing with this layered on top of operating system primitives?
|
|
#3
|
||||
|
||||
|
Quote:
__________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#4
|
|||
|
|||
|
Quote:
Well, I think that if you are working with a standard console application you could use the <conio.h> include, and use its getch() function to get the key pressed. Example: char input; input=getch(); Then you could compare its value with the ASCII value of the key you wanted in your if statement. if ( input == ASCII value of up arrow ) // mean up arrow key cout<< " up arrow key "; You could also use this to check for any other key. Hope this gives you an idea. |
|
#5
|
||||
|
||||
|
Quote:
u suggestion are good, but i try before arrowkey is not a standard input (i guess so) even use getch() also nothing happen __________________
challenges are make life interesting, overcome them is make life meaningful. |
|
#6
|
||||
|
||||
|
Quote:
The function and arrow keys are 2-character keys. First char is 0, 2nd char is the key. The following shows how to access the keys and will also give you the key-commbinations: CPP / C++ / C Code:
__________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#7
|
||||
|
||||
|
Quote:
sorry C i not really well, can u explain more a bit to me i try to convert to c++ but unfortunately the output is different __________________
challenges are make life interesting, overcome them is make life meaningful. |
|
#8
|
||||
|
||||
|
CPP / C++ / C Code:
CPP / C++ / C Code:
Just compile the program and see what it does... __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#9
|
||||
|
||||
|
thx WaltP
1 more question if we mix with c and c++ will it cause any problem? __________________
challenges are make life interesting, overcome them is make life meaningful. |
|
#10
|
||||
|
||||
|
You can mostly use C with C++ (namespaces tend to divide the two), but don't try using C++ if you're using a compiler that only works for C.
__________________
-Aaron |
Recent GIDBlog
Stupid Management Policies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| scanf / clearing input stream | zone4 | C Programming Language | 8 | 08-May-2004 15:42 |
| IP tables | rogermark100 | C Programming Language | 6 | 18-Apr-2004 08:22 |
| Help with array and function input | FearlessFife35 | C Programming Language | 13 | 16-Apr-2004 15:10 |
| Need Help on checking user input | hihellochao | C Programming Language | 5 | 27-Feb-2004 14:30 |
| Script needed for letting user input a few days of data for tracking and analysis. | tradertt | MySQL / PHP Forum | 3 | 06-Mar-2003 03:54 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The