Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++, please! When you're processing data, it's useful to break up a text string into pieces using a delimiter. Write a function split that

image text in transcribed

image text in transcribed

In C++, please!

When you're processing data, it's useful to break up a text string into pieces using a delimiter. Write a function split that takes and split a string on a delimiter, then it populates the array of strings with the split pieces up to the provided maximum number of pieces. Function specifications: The function name: split The function parameters (in this order): o The string to be split. A separator, character, which marks where the string should be split up An array of string, where the split-apart string pieces will be stored The size of the array, int The function returns the number of pieces the string was split into as an integer. Your function does not print anything. Important considerations: If the string is split into more pieces than the size of the array, then the function returns -1. If the delimiter character is not found, then the function returns 1 and the entire string is placed in the array as the first element. You can assume: 1. There will not be consecutive delimiters 2. The delimiter will not be the first or the last character in the string For example: string words [10]; split("cow/chicken/fish", '/', words, 10); would return 3 and fill the array with "Cow", "chicken", "fish". Sample run 1 (bold is user input; the array size is 4) Enter the text: Apples, Oranges, Bananas Enter the separator: Return value: 3 arr[0] = Apples arr[1] = Oranges arr[2] Bananas = Sample run 2 (bold is user input; the array size is 4) Enter the text: 2020/03/11 Enter the separator: / Return value: 3 arr[0] = 2020 arr[1] = 03 arr [2] = 11 Sample run 3 (bold is user input; the array size is 4) Enter the text: Tokyo , Bangalore, Boulder, London, Seattle Enter the separator: Return value: -1 arr[0] = Tokyo arr[1] = Bangalore arr[2] Boulder arr[3] London There are 5 cities, but the size of the array is 4. Since it's more than the size of the array, the split function returns -1

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

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

1. Television more Over watching faceing of many problems ?

Answered: 1 week ago

Question

Is there a link between chronic stress and memory function?

Answered: 1 week ago

Question

5. A review of the key behaviors is included.

Answered: 1 week ago