Ignoring extraneous characters in input

Feb 9, 2015 at 12:03am
Hey! Working on a project and I need help with ignoring extraneous characters. For the input you have to input a dollar amount (ex. 1000). I need to write in C++ to accept the input but also to either accept or just ignore extraneous characters. I've seen other archived answers but they don't answer my question really. I need it to ignore stuff like "$ 1000" or "$1000" or "1000 dollars" and just accept the numeric characters. Any ideas?
Feb 9, 2015 at 12:05am
Maybe you could use cin.peek()?
Feb 9, 2015 at 12:08am
how so? this is my code

1
2
    cout << "What is your loan amount? ($ Amount)";
    cin >> loanamt;


how can I use cin.peek
Topic archived. No new replies allowed.