string ss = "1-1-10-8-9";
There is a string like above. I want to add element to string array between "-"
string vector should be same as below
vector<string> str = {"1", "1", "10", "8", "9"};
string ss = "1-1-10-8-9";
There is a string like above. I want to add element to string array between "-"
string vector should be same as below
vector<string> str = {"1", "1", "10", "8", "9"};
#include <iostream>
#include <sstream>
#include <vector>
int main() {
std::stringstream ss("1-1-10-8-9");
std::vector<std::string> v;
std::string s;
while(std::getline(ss, s, '-')) {
v.push_back(s);
}
return 0;
}