Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ ONLY The split function from Homework 5 was such a blast, lets do it again, but with an array this time! Write a new

C++ ONLY

The split function from Homework 5 was such a blast, lets do it again, but with an array this time! Write a new function split which takes four input arguments: a string to be split, a character to split on (a delimiter), an array of strings to fill with the split pieces of the input string, and an integer representing the maximum number of split string pieces. The function will split the input string in to pieces separated by the delimiter, and populate the array of strings with the split pieces up to the provided maximum number of pieces. Your function will return the number of pieces the string was split into.

  • Your function should be named split

  • Your function takes four input arguments:

    • The string to be split.

    • A delimiter character, which marks where the above string should be split up.

    • An array of string, which you will use to store the split-apart string pieces.

    • The int length of the given array

  • Your function returns the number of pieces the input string was split into as an integer.

  • Your function does not print anything.

  • If the input string is split into more pieces than the array of string can hold (more than the indicated length), your function should fill only as many words as it can, and return -1.

string words[10]; split("cow/chicken/fish", '/', words[], size ); 

would return the count of 3 and fill the array with "cow", "chicken", "fish".

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How do you verify and validate the Operations Domain Solution?

Answered: 1 week ago

Question

3:35 Answered: 1 week ago

Answered: 1 week ago

Question

c. What were you expected to do when you grew up?

Answered: 1 week ago

Question

d. How were you expected to contribute to family life?

Answered: 1 week ago

Question

e. What do you know about your ethnic background?

Answered: 1 week ago