need some help with defining keys.

This is a discussion on need some help with defining keys. within the C++ Programming forums, part of the General Programming Boards category; I have a defining problem if anyone care to help me:P Im trying to define diferent keys on the keyboard ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    25

    need some help with defining keys.

    I have a defining problem if anyone care to help me:P
    Im trying to define diferent keys on the keyboard to do
    things in a program. but I cant make it work.


    #define K 4b
    if (K=='1')
    {i++}

    can I define something like this and make it work anywhere in
    a big program.

  2. #2
    Registered User stillwell's Avatar
    Join Date
    Aug 2004
    Posts
    80


    Sorry, but even the newbie I am can see that is just horribly wrong.

    Also, read the rules before you post. Some of these guys are pretty strict about posting the way you do.

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Well you can do that, but its not gonna do anything. Lets expand out the macro and you get

    Code:
    if ( 4b == '1' )
    {
      i++;
    }
    So unless the character 1 happens to have a decimal value of 4 it will always be false.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simulate Keys with a Keyboard Hook
    By guitarist809 in forum Windows Programming
    Replies: 3
    Last Post: 11-14-2008, 07:14 PM
  2. blocking or passing keys with global hook
    By pmouse in forum Windows Programming
    Replies: 4
    Last Post: 08-29-2007, 02:54 PM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM

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