Can't quite figure this out

I have to read in a line and get this output:

in: convert 2-9
out: 29-
in: quit

I can't get the program to quit when 'quit' is typed in because I am using:

convert C1;
string str1;

getline(cin, str1, ' ');
C1.readin();


In this, convert is a class.

This is making sure the word convert was typed and then saving the part after the space so I convert it later. The problem I am having is when 'quit' is entered there is no ' ' entered so the program doesn't quit. Is there a way I can make getline stop reading input under two conditions ' ' and '\n'? Or am I going about this all wrong?

thanks,

sch518
why not just do if(command == "quit")
exit(int);
cin >> str1;

This is the overload of the global operator >> used for std::strings
http://www.cplusplus.com/reference/string/operator%3E%3E/

It will stop reading at the first whitespace
try getline
Topic archived. No new replies allowed.