Answered! Given the following function header: vector split(string target, string delimiter); implement the function split so that…

In c++, Given the following function header: vector string> split (string target, string delimiter) implement the function split so that it returns a vector of the strings in target that are separated by the string delimiter For example: split(10,20,30 should return a vector with the strings 10, 20, and 30. Similarly, split(do re mi fa so la ti do should return a vector with the strings do, re, mi, fa, so, la, ti, and do Write a program that inputs two strings and calls your function to split the first target string by the second delimiter string and prints the resulting vector all on line line with elements separated by commas. REQUIRED: You MUST use vectors to write this program. You may not use any C++functions that we have NOT discussed in lecture. The strings printed by the program should include a newline at the end. The program should print a string of text to the terminal before getting each line of input from the user. A session should look like one of the following examples (including whitespace and formatting), with possibly different numbers in the output: Enter Btring to split: 10,20,30 Enter delimiter string: The substrings are 10, 20 30 OR Enter string to split: do re mi fa so la ti do Enter delimiter string: The substrings are do, re, mi, fa, so la, ti, do Note: the fourth line in the second example has a single space character (it is not an empty line).Given the following function header: vector split(string target, string delimiter); implement the function split so that it returns a vector of the strings in target that are separated by the string delimiter. For example: split(“10,20,30”, “,”) should return a vector with the strings “10”, “20”, and “30”. Similarly, split(“do re mi fa so la ti do”, “ “) should return a vector with the strings “do”, “re”, “mi”, “fa”, “so”, “la”, “ti”, and “do”. Write a program that inputs two strings and calls your function to split the first target string by the second delimiter string and prints the resulting vector all on line line with elements separated by commas. REQUIRED: You MUST use vectors to write this program. You may not use any C++ functions that we have NOT discussed in lecture. The strings printed by the program should include a newline at the end. The program should print a string of text to the terminal before getting each line of input from the user. A session should look like one of the following examples (including whitespace and formatting), with possibly different numbers in the output: Enter string to split: 10,20,30 Enter delimiter string: , The substrings are: “10”, “20”, “30” OR Enter string to split: do re mi fa so la ti do Enter delimiter string: The substrings are: “do”, “re”, “mi”, “fa”, “so”, “la”, “ti”, “do” Note: the fourth line in the second example has a single space character (it is not an empty line).

Expert Answer

 #include<iostream>

#include<vector>
#include<string>
#include<sstream>
using namespace std;

Don't use plagiarized sources. Get Your Custom Essay on
Answered! Given the following function header: vector split(string target, string delimiter); implement the function split so that…
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

int main()
{
string inputstring;
char delimeter;
cout<<“enter the input string”<<endl;
cin>>inputstring;

istringstream ss(inputstring);
string tokens;
vector<string> infoVector;
while(std::getline(ss, tokens,’ ‘)){
infoVector.push_back(tokens);
cout << tokens << ‘n’;
}

return 0;
}

Still stressed from student homework?
Get quality assistance from academic writers!