How can i split a string into vector in substring? My code:
#include <iostream>
#include <vector>
using namespace std;
vector<string> split(string str, string delim)
{
//How can I do it here?
}
int main()
{
string str = "Hello\n_SPLITING_\nWorld!\n_SPLITING_\nHappy Coding!";
vector<string> output = split(str, "\n_SPLITING_\n");
for(int i = 0; i != output.size(); i++)
{
cout << output[i] << ";" << endl;
}
}
and i want the output be:
Hello;
World!;
Happy Coding!;
Aucun commentaire:
Enregistrer un commentaire