testing for symbols

This is a discussion on testing for symbols within the C Programming forums, part of the General Programming Boards category; Is it possible for C to test and see if the "*", "+", "-", and the "/" key are pressed ...

  1. #1
    Registered User
    Join Date
    Jul 2007
    Location
    Texas
    Posts
    103

    testing for symbols

    Is it possible for C to test and see if the "*", "+", "-", and the "/" key are pressed (just the math functions). And if it is how could you go about doing it?

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    If you mean at the console, read in character press into an int variable, and then do a test.

    Code:
    int c;
    
    ....
    
    c = getchar();
    if(c == '*')
    {
    	/* '*' was pressed. */
    }
    If you mean asynchronously whenever the keys are pressed, then you gotta do it differently.

  3. #3
    Registered User
    Join Date
    Jul 2007
    Location
    Texas
    Posts
    103
    Nvm I am a moron.. I just figured it out...

  4. #4
    Registered User
    Join Date
    Jul 2007
    Location
    Texas
    Posts
    103
    Ya, that is what I did.. thanks anyway :-)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL: Depth Testing, Matrixes, ect.?
    By Zeusbwr in forum Game Programming
    Replies: 8
    Last Post: 12-08-2004, 08:37 AM
  2. C++ bit testing
    By Vicious in forum C++ Programming
    Replies: 3
    Last Post: 09-19-2004, 11:44 AM
  3. Blending and Depth Testing
    By Thunderco in forum Game Programming
    Replies: 2
    Last Post: 03-08-2004, 05:37 PM
  4. program for Radiation Testing
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 02-07-2002, 12:47 AM
  5. Testing Testing 123.. Oh yeah and...
    By minime6696 in forum Windows Programming
    Replies: 0
    Last Post: 08-13-2001, 09:07 AM

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