This question already has an answer here:
- How do I tokenize a string in C++? 33 answers
- Split string by single spaces [duplicate] 7 answers
Scenario:
Unfortunately due to some legacy code, I have a std::string
which contain some int values and separated by spaces like this:
std::string legacy_code_string = "3 8 7 10 5 16";
Note that the common delimiter used in a space " "
and all values are int
s.
I want to create an std::vector<int>
out of this
std::vector<int> GetVectorFromEncodedValuesInString(const std::string & str) {
}
Question:
How I can do this the best way possible?
Aucun commentaire:
Enregistrer un commentaire