What happens when you press "enter" without providing the program input?

I tried googling this but found nothing but people wanting to gather input without the user pressing enter.

When I provide a prompt for user input and the user only presses enter, the screen advances one line while still waiting for input.

How do I determine whether or not that happened so I can do something about it? I tried testing to see if the input is empty(), but that doesn't work.

Thanks in advance.
Hello CVRIV,

That would depend on how you are collecting the input.

"std::getline()" will allow you to press enter and create an empty string.

Formatted input will always be waiting for more than just "Enter".

Without seeing the code that you have tries or ar using I have no ideay what you are trying to do.

Andy
I'm just using "cin >>"
You can read the entire line of input with std::getline then test whether or not the line was empty.

std::cin >> thing ignores white-space by default, typically.
Last edited on
Topic archived. No new replies allowed.