Thread: Ignoring certain characters in input

  1. #1
    Registered User
    Join Date
    Mar 2010
    Location
    Australia
    Posts
    174

    Ignoring certain characters in input

    I need to getchar digits, but ignore spaces and dashes '-'
    I'm thinking something like this:

    Code:
    	if (one == '-' || one == ' ') {
    		(do not getchar)
    	} else {
    		one = getchar ();
    	}
    What can I replace with (do not getchar) so that the program skips that character and goes and looks at the next character and in the meantime, starting at the if statement again rather than going on further.
    Maybe a while statement? But I wouldn't know what to say such that it keeps repeating this loop until the program goes to the one = getchar (); line.
    Note: I can't use breaks or go to

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If you want to continue the loop without doing the rest of it, you type "continue".

  3. #3
    Registered User
    Join Date
    Mar 2010
    Location
    Australia
    Posts
    174
    Ok I'll give that a shot. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 09-16-2009, 06:00 AM
  2. Input class project (again)
    By Elysia in forum C++ Programming
    Replies: 41
    Last Post: 02-13-2009, 10:52 AM
  3. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  4. Problem grabbing k/b input
    By falcon9 in forum C Programming
    Replies: 2
    Last Post: 10-28-2007, 11:47 AM
  5. Keyboard input: Array of characters
    By metric1969 in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2003, 04:43 PM