Thread: Ending user input with # character

  1. #1
    Registered User
    Join Date
    Apr 2004

    Ending user input with # character


    I'm a newbie here so sorry if this seems a dumb question. I have to get a user input. Normally I just use
    which ends the user input when the ENTER key is pressed. But I may need ENTER to form part of the input so I need to end the input with a '#' character. Does this make sense?

    any ideas?

    Thanks in advance, Jo

  2. #2
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    I think you can use getline(), and specify '#' as the delimiter.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  3. #3
    Registered User major_small's Avatar
    Join Date
    May 2003
    this is what it would look like:
    char line[256];
    according to url=]this definition[/url], it will still stop at a newline or EOF character... I'm not sure what will happen if you send getch() a newline, but it'll probably come out with better results...

    here's a little info on getch():
    Last edited by major_small; 04-27-2004 at 10:54 AM. Reason: fixt error
    Join is in our Unofficial Cprog IRC channel
    Channel: #Tech

    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 04-03-2008, 09:07 PM
  2. How do I input an unbuffered character via the keyboard???
    By Michael_in_Ohio in forum C Programming
    Replies: 1
    Last Post: 03-23-2008, 12:00 PM
  3. User determined input question
    By lyoncourt in forum C Programming
    Replies: 8
    Last Post: 09-30-2007, 06:10 PM
  4. Nested Structures - User Input
    By shazg2000 in forum C Programming
    Replies: 2
    Last Post: 01-09-2005, 10:53 AM
  5. Getting user input without echo to terminal
    By cliff78 in forum C Programming
    Replies: 1
    Last Post: 04-27-2004, 08:03 PM