Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C++ 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

in C++

image text in transcribedimage text in transcribed

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 a string, splits it at every occurrence of a delimiter, and then populates an array of strings with the split pieces, up to the provided maximum number of pieces. . O Function specifications: The function name: split The function parameters (in this order): The string to be split A separator, char, 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 should not print anything The function returns the number of pieces the string was split into, as an integer. O O O Note: . No input will have delimiters in the beginning or the end of the string. (Eg: ,apple, orange OR apple, orange,) No input will have multiple delimiters added consecutively. (Eg: apple,,,orange, banana) . 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. If the string is split into more pieces than the size of the array (the last parameter), then the function returns -1. . 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 the array size is 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_2

Step: 3

blur-text-image_3

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

Please make it fast a . 8 8 6 .

Answered: 1 week ago