c++ splitstring example

include

include

include

include

int main() { std::string sentence = "This is a sample sentence"; std::vector words; std::stringstream ss(sentence); std::string word;

while (getline(ss, word, ' ')) {
    words.push_back(word);
}

for (auto &w : words) {
    std::cout << w << std::endl;
}

return 0;

}