Do something when ctrl+d is pressed.

This is a discussion on Do something when ctrl+d is pressed. within the C Programming forums, part of the General Programming Boards category; Hello, I need to do something when ctrl d is pressed and i dont know how to compare the ascii. ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    11

    Do something when ctrl+d is pressed.

    Hello, I need to do something when ctrl d is pressed and i dont know how to compare the ascii. for example:
    Code:
    if(input == ctrl+d ){
              // do this
    }

  2. #2
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    Check for EOF. See feof - C++ Reference for how to do so.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Randellk02 View Post
    Hello, I need to do something when ctrl d is pressed and i dont know how to compare the ascii. for example:
    Code:
    if(input == ctrl+d ){
              // do this
    }
    CTRL-D is ASCII code 0x04...

    When you press CTRL you are resetting bit 6 of the standard ascii letter value.
    Pressing SHIFT sets bit 5.

    if (input = 4)...

    Here's an ASCII chart for you to consult in future...
    ASCII Codes - Table of ascii characters and symbols
    Last edited by CommonTater; 11-07-2010 at 12:48 AM.

  4. #4
    Registered User
    Join Date
    Nov 2010
    Posts
    11
    Thanks for the replies, I am good to go.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    Now depending on which OS/Compiler you're using, one of the two previous answers will be wrong
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading Ctrl D in fgets with some inputs
    By CashCow01 in forum C Programming
    Replies: 7
    Last Post: 03-21-2010, 12:34 AM
  2. C - until pressed
    By yann in forum C Programming
    Replies: 7
    Last Post: 09-08-2009, 11:51 AM
  3. Check if a key has been pressed and released
    By xkrja in forum Windows Programming
    Replies: 3
    Last Post: 09-19-2006, 09:06 AM
  4. Replies: 2
    Last Post: 07-25-2003, 03:01 AM
  5. how do you know when enter is pressed?
    By pinkcheese in forum Windows Programming
    Replies: 6
    Last Post: 07-26-2002, 12:45 PM

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