blank in cin

closed account (1vf9z8AR)
How can a user ignore a cin.Like enter nothing in a particular line where value is asked.
cin already ignores whitespace for normal (>>) usage. So it will give you an empty string result assuming you are reading a string.

how you handle the empty input depends on whether the value is optional or not, but its up to your code to do the correct thing here, which is usually allow empty or loop until valid (or a combination, if there are invalid non empty entries)

if your program is stuck and unable to proceed, you may need to use cin.getline instead.
Last edited on
Topic archived. No new replies allowed.