Character for Up Arrow

This is a discussion on Character for Up Arrow within the C++ Programming forums, part of the General Programming Boards category; Hey, I am making a simple menu program in the DOS Console. I've got the whole program to work exept ...

  1. #1
    Registered User BigSter's Avatar
    Join Date
    Nov 2001
    Posts
    47

    Character for Up Arrow

    Hey,

    I am making a simple menu program in the DOS Console. I've got the whole program to work exept for I have to use w and x for up and down. I was wonder what were the characters for the actual up, down, left, and right arrows, and how can I get those characters in my code using DEV-CPP. Here is what I have.
    -Thanks

    #include <stdio.h>
    #include <iostream.h>

    int main()
    {

    while(1){
    char a_char;
    a_char=getchar();

    switch(a_char){
    case 'w': //This is where I want the up arrow character
    cout<<"This is the up arrow"<<endl;
    break;

    case 'x': //This is where I want the down arrow character
    cout<<"This is the down arrow"<<endl;
    break;
    }
    }
    return 0;
    }

  2. #2
    Unregistered
    Guest
    usually I use this program to find out what int value certain
    key strokes have.....
    however in the case of the arrows it seems that the system accepts each of the nav arrows as two key strokes....

    maybe you should consider GetAsyncKeyState(...) in the using the windows.h file....


    Code:
    #include<iostream.h>
    #include<conio.h>
    
    
    
    void main( void )
    {
    
    	int chVal;
    
    	while( 1 )
    	{
    		while( !kbhit() );
    
    		chVal = getch();
    
    		cout << "\n" << chVal << endl;
    
    		if( chVal == (int)'q' || chVal == (int)'Q')
    			break;
    	}
    }

  3. #3
    Registered User BigSter's Avatar
    Join Date
    Nov 2001
    Posts
    47

    Cool

    Okay,
    I made this program:

    #include <stdlib.h>
    #include <iostream.h>

    int main(){
    while(1){
    int keystroke;

    cout<<"Type a Key"<<endl;
    cin>>keystroke;
    cout<<keystroke<<endl;
    }
    }

    I then found out that the up arrow displays a "fish looking symbol" and then h. The downarrow displays a "fish looking symbol" and then j. How can I get the "fish looking symbol" in my code, and how can I merge the two to make one keystroke.

    Thanks

  4. #4
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    if you execute interrupt 0x16 with ax being 0x00, you get the scan code [which is like, 77 80 75 72 for arrows] in the ah, and the ascii code in the al, and you can make a more general input function using this, which would give you more flexibility.
    hasafraggin shizigishin oppashigger...

  5. #5
    Registered User Sekti's Avatar
    Join Date
    Feb 2002
    Posts
    163

    Can you...

    say that in easier to understand words

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Character literals incorrectly interpreted
    By DL1 in forum C Programming
    Replies: 11
    Last Post: 04-05-2009, 06:35 PM
  2. Using a character array in a switch question.
    By bajanElf in forum C Programming
    Replies: 10
    Last Post: 11-08-2008, 08:06 AM
  3. <string> to LPCSTR? Also, character encoding: UNICODE vs ?
    By Kurisu33 in forum C++ Programming
    Replies: 7
    Last Post: 10-09-2006, 01:48 AM
  4. Remove character from string
    By nooksooncau in forum C Programming
    Replies: 11
    Last Post: 06-05-2006, 10:37 AM
  5. Character handling help
    By vandalay in forum C Programming
    Replies: 18
    Last Post: 03-29-2004, 05:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21