Pls answer the following: Thanks 3. Strings Answer the following questions regar
ID: 645852 • Letter: P
Question
Pls answer the following:
Thanks
3. Strings Answer the following questions regarding string type: (a) (9 points) Show how to use one or more string member functions that do the following tasks. i. Given a string S, find the substring F of S which is the stung S with its first and last letters missing. (Assume S has 2 or more kites.) ii. Create the string S initialized to THIS IS SO FUN. iii. Create a string stream initialized to the string S. (6) 10 points) Write a C++ (unction implode that manes an array of string type, length of array, and a delimiter string. This function returns a single string that is the elements of the array concatenated together with the delimiter string between each element. For example, suppose array A contains elements {Mary, Bob, Joe}, then implode (A, +) will return string Mary, Bob+, Joe.Explanation / Answer
i) F = S.substr(1,S.length()-2);
ii) string S = "THIS IS SO FUN";
iii) stringstream ss(S);
b)
string implode(string array[], int length, string delimiter){
string result = "";
for(int i=0; i<length; i++){
if(i!=length-1)
result += array[i] + delimiter;
else
result += array[i];
}
return result;
}