How to store a string into a vector?

Given a string such as this:
These,Are,The,Words,To,Store

How could I make a vector that stores each word as a string, separating them into elements determined by the commas? aka, 'These' would be stored in 0, 'Are' stored in 1, etc.

Thank you for any help.
There are several ways to do that.

You can use the function find() and substr(). See:

http://www.cplusplus.com/reference/string/string/?kw=string


Or you can use stringstream. See:

http://www.cplusplus.com/reference/sstream/stringstream/?kw=stringstream

In order to get the word and store them in a vector (with push_back()). See:

http://www.cplusplus.com/reference/vector/vector/?kw=vector
Topic archived. No new replies allowed.