Make a function that takes as an input a character array and an array of integer
ID: 3832623 • Letter: M
Question
Make a function that takes as an input a character array and an array of integers. This function should return a dynamically created string array, created by combining the char array into words of length denoted by the int array. More specifically, the first element in the integer array denotes how many characters from the character array comprise the first word. The second element in the integer array indicates that those many letters after the first word in the character array are the second word. And so on.... Example: char words[] = {'h', 'i', 't', 'h', 'e', 'r', 'e', 'c', 'l', 'a', 's', 's'}; int lens[] = {2, 5, 5);//The above input into your function should return a string array://{"hi", "there ", "class"}Explanation / Answer
I am working on it. As soon as i am done i will update the solution here.
#include <iostream>
using namespace std;
string combine(char words[] ,int lens[]){
string arrayTwo [arraySize];
}
int main()
{
string str[];
char words[]={'h','i','t','h','e','r','e','c','l','a','s','s'};
int lens[]={2,5,5};
combine(words,lens);
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.