split text c++
#include <iostream>
#include <sstream>
#include <vector>
int main() {
std::string input_text = "This is a sample text to split in C++.";
std::istringstream iss(input_text);
std::vector<std::string> words;
do {
std::string word;
iss >> word;
words.push_back(word);
} while (iss);
// Display the split words
for (const auto& word : words) {
std::cout << word << std::endl;
}
return 0;
}