can arrow keys be used in C++

arrow keys will need to be used in the output of the c++

Page 1 of 1

1 Replies - 6976 Views - Last Post: 29 February 2008 - 05:48 AM Rate Topic: -----

#1 harpy_125  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 22-February 08

can arrow keys be used in C++

Post icon  Posted 29 February 2008 - 05:03 AM

hey guys, is it possible to use arrow keys in C++.
our proffessor wants us to make a 10X10 SOS game (if you know that game, it is similar to tictactoe difference is that instead of straight XXX need to be form the word (s-o-s) should be form instead).

anyway back to the topicl, arrow keys will be used so that the player (user) can choose a box where the letter 'S' or 'O' will be placed. my friend say there is a code/value that is needed. but i don't know what is the value of arrow keys. can any one help about it??? please

Is This A Good Question/Topic? 0
  • +

Replies To: can arrow keys be used in C++

#2 AmitTheInfinity  Icon User is offline

  • C Surfing ∞
  • member icon

Reputation: 109
  • View blog
  • Posts: 1,530
  • Joined: 25-January 07

Re: can arrow keys be used in C++

Posted 29 February 2008 - 05:48 AM

if you are making that on DOS then I think int86() should help you. It generates interrupt and from that you can get the value for key hit. Then map the value to see which key has been pressed [interrupt 22h I guess]. Seems bit difficult :blink:

Or easiest way is write a simple function which uses getch() and gives you the value of key pressed. [This is what I used to do for my assignments]

something like this
        int ch;
        ch = getch();    
        ch = getch();
        printf("\nkey pressed = %d", ch);



now use this code itself to get what are the values for your arrow keys [use mostly for special keys] and use them in your code.

I hope this will help you. :)

This post has been edited by AmitTheInfinity: 29 February 2008 - 06:02 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1