Question: Write a function Split(...) that is given a string, a separator character, an array to fill and the max number of elements in the array
Write a function Split(...) that is given a string, a separator character, an array to fill and the max number of elements in the array as parameters and returns an integer result. The function will separate each substring of the given string between separator characters and place it in the array. The function returns the number of substrings extracted.
For example: Split("cow/chicken/fish", '/', words[], size ) would return the count of 3 and fill the array with "cow", "chicken", "fish"
use c++
int Split (string str , char e, string words[ ], int size ) { words[0]=str; int h=0; int f =0; int c=1; if(str.length()==0) { c=c-1; } else { for(int i=0;i return c; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
