Ending a loop by pressing 'return'

I've been looking around trying to see how to end a loop by just pressing enter, or essentially a blank entry. The idea is that the user will be entering a process name and the loop will continue to accept entries until the user enters a blank, meaning doesn't enter anything such as just hitting enter. I was trying to use just

1
2
3
4
while( processName != '\n' )
{
     getline( cin, processName )
}


or something to that effect, but it doesn't seem to recognize the return press as a character.
getline() strips off the newline when before it writes into the string. Check if processname is empty.
You can use the following code

1
2
3
4
while ( std::cin.peek() != '\n' )
{
   getline( std::cin, processName );
}
Topic archived. No new replies allowed.