I have a vector<string> and a string "hello,world". I want the vector to end up containing {"hello," , "world"}. I know enough about string member functions to make these two strings, but I'm confused about how to initialize this vector.
If the vector were a string:
1 2
string str = "hello,world", piece;
piece.assign(str, 0, str.find_first_of(',')); // (I think thats about right)
How do I assign an element of the vector if the vector doesn't have any elements in it to begin with? I'm looking for something like vct.push_back(string between these two positions). Even if the vector was an array of strings, I still have issues.
granted, manually parsing string like that is not the best practice, there are many ways to split strings into tokens. boost library in particular has a lot.