scanf() <-> esc key

This is a discussion on scanf() <-> esc key within the C Programming forums, part of the General Programming Boards category; Hi all! I'm using the function scanf but I looking for another function can get user string from the console ...

  1. #1
    ipe
    ipe is offline
    Registered User
    Join Date
    Jan 2003
    Posts
    52

    scanf() <-> esc key

    Hi all!

    I'm using the function scanf but I looking for another function can get user string from the console becuse:
    1- I'd like a function that when the user type ESC key it stop asking for some string input
    2- I'd like a non-multile type.

    for ex: "type the path where the file is located"
    > [here goes the scanf() but it will take lots of '\n' on console if the user type enter key without at least a char input]

    Thanks for any suggestion!

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Try in here
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,676
    If its not in the FAQ, you can search the board for what you're looking for.....you will things like this.

    gg

  4. #4
    ipe
    ipe is offline
    Registered User
    Join Date
    Jan 2003
    Posts
    52
    i tried the faq but i found nothing.
    I tried this:
    Code:
    cc = getche();
    while (cc != 13 || cc != 27)
    {
    ...
    cc = getche();
    }
    but don't worked

  5. #5
    ipe
    ipe is offline
    Registered User
    Join Date
    Jan 2003
    Posts
    52
    cool.
    Code:
    char path[100]
    int a;
    
    cc=getche();
    
    while (cc != 13 && cc != 27)
    {
    	cc=getche();
    	path[a++]=cc;
    }
    in the line path[a++]=cc; may have a better way to do that, isn't it?
    strcat would be fine but should be CHARcat

  6. #6
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    Dont forget to initialze 'a' in your example.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 12:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 09:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM

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