#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
string str="23 156 1645 -2398 77";
vector<string> words;
char delimeter=' ';
int n=str.size();
for(int i=0;i<n;i++)
{
int j=i;
while(str[i]!=delimeter && i<n)
i++;
string temp=str.substr(j,i-j);
words.push_back(temp);
}
return 0;
}
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
vector<string> string_burst(string str,char delimeter)
{
//condition: works with only single character delimeter, like $,_,space,etc.
vector<string> words;
int n=str.length();
for(int i=0;i<n;i++)
{
int j=i;
while(str[i]!=delimeter && i<n)
i++;
string temp=str.substr(j,i-j);
words.push_back(temp);
}
return words;
}
#include <string.h>
int main ()
{
char str[] ="This is a sample string";
char *p;
p=strtok(str," ");
while (p!= NULL)
{
cout<<p;
p=strtok(NULL," ");
}
return 0;
}
#include <boost/algorithm/string.hpp>
std::string text = "Let me split this into words";
std::vector<std::string> results;
boost::split(results, text, [](char c){return c == ' ';});