Hello All,
Is there anyway to break up getline by 'spaces' and insert each word into a vector?
I have the user stop at '.'. My code is as follows - it just inserts the whole string into a vector.
How would I get something if the user types in this:
Break Me Up.
into a vector (separated by words) like this
Break
Me
Up
Any help greatly appreciated! - pandadc
Code:int main() { vector< string > texts; string usertext; cout << "Please enter some text." << endl; getline(cin, usertext, '.'); texts.push_back(usertext); for (unsigned int i = 0; i < texts.size(); i++) cout << texts.at(i) << endl; return 0; }



LinkBack URL
About LinkBacks



CornedBee