Using getline for menu selection

So I am trying to create a menu system with a while loop, and the input to make selections for the menu has to be a string. To quit, the user types "quit", but the other selections require that the user types in their choice, followed by a file name in quotes (Example: count bytes in file "input.txt"). I used getline to capture input, and for the menu items other than "quit", it works fine. The problem occurs when I input quit, the program just hangs. I'm guessing that my use of a delimiter with getline is making the system wait for it, but I don't know how to accept the input in a way that allows for both possibilities.

1
2
3
4
5
6
7
8
9
	
	cout << "Command: ";
	getline(cin, userIn, '\"');
	getline(cin, inName, '\"');
	cin.ignore(8192, '\n');
	for (unsigned int i = 0; i < userIn.length(); ++i) {
		userIn[i] = tolower(userIn[i]);
	}
Last edited on
Topic archived. No new replies allowed.