Question about Switch Case Statement

What I have is a Switch Case where I allow the user to enter up to 7 characters to be processed. But they are free to enter fewer than 7, As it happens right now, if the user enters IX and hits enter, the system will just wait for the final 5 characters to be entered.

So I put in a default case that would stop the process if they entered any character not featured in the Switch Case statement. So for example, p is a character not featured.

so IXp
is what the user would have to enter right now, to get a value for IX without having to enter 5 more characters.

Enough of that:
~~~~---THE QUESTION---~~~~~~~
Is it possible/How can I make it so that even though I prompt the user to enter 7 characters, they can still enter only 6 or less and simply press enter to finish the process.

Such as, simply entering 12 or IV and hitting enter to end the process.

(I know this sounds confusing. But I hope someone understands wtf I'm talking about.)
Post the code that is not working and we'll tell you how to fix it.
Just an idea, because it's hard to tell without the code snippet - have you tried cin.ignore? Syntax is found here http://www.cplusplus.com/reference/iostream/istream/ignore.html - basically what it does is terminates an input on enter.

You could also fill in the whitespace automatically, though that might be more complex.
Last edited on
yeah I took a closer look through some of my books and found out about cin.get

Which is what I used. I didnt post code because, well, I had a problem with the idea and not the code.

It's solved atm, thanks!
Topic archived. No new replies allowed.