Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- std::vector<std::string> split(std::string source, std::string delimiter) {
- std::vector<std::string> tmp;
- size_t start = 0, end = 0;
- while((end = source.find(delimiter, start)) != std::string::npos) {
- tmp.push_back(source.substr(start, end - start));
- start = end + 1;
- }
- tmp.push_back(source.substr(start, source.length()));
- return tmp;
- }
- int main() {
- std::vector<std::string> d = split("ja vai embora", " ");
- for(int z=0; z!=d.size(); z++) {
- std::cout << d.at(z) << std::endl;
- }
- std::cout << "Hello World" << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement