Question
Split function Given the following header: vector split(string target, string delimiter);, implement the function split so that it returns a vector of the strings in
Split function
Given the following 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".
Demonstrate the function by sending at least 3 strings to the function and displaying the results.
Note: I manually added the square brackets to indicate that the results are a vector. You can't output those automatically (e.g., cout
String test #1: "10,20,30,40" and the delimiter is a comma: Resulting vector: [ 10 20 30 40 ] String test #2: "do re mi fa so la ti do" and the delimiter is a space: Resulting vector: [ do re mi fa so la ti do ] String test #3: "north|south|east|west" and the delimiter is a vertical bar: Resulting vector: [ north south east west ] Process exited after 0.2173 seconds with return value o Press any key to continueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started