1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GrogVix [38]
3 years ago
5

Now, extend your test program by adding a second function named split that will identify all the individual values in a comma se

parated value string and return them in an array of string objects: int split(string str, string a[], int max_size); Your function will take three arguments: a comma separated value string str, an array a of string objects, and the maximum size of the array. You must use the nextString function from Stretch Problem (1) to obtain each value in the string and store it in the array starting, with the first element. Return the total number of values stored in the array. For example: string varray[VALUES]; 2 int cnt

Computers and Technology
1 answer:
otez555 [7]3 years ago
7 0

Answer:

The code to copy is :

#include <iostream>

#include <string>

using namespace std;

string nextString(string str, int start_index);

int split(string str, string a[], int max_size);

int main()

{

const int VALUES = 20;

string somestring;

string varray[VALUES];

//Prompt the user to enter a comma separated string

cout << "Enter a comma seperated string: ";

//read the string

getline(cin, somestring);

//call split() method on the given string and

//store the count of individual strings in cnt

int cnt = split(somestring, varray, VALUES);

//Print the individual strings

for (int i = 0; i<cnt; i++)

cout << varray[i] << endl;

return 0;

}

//returns a sub string that starts at strat_index

//in the given string and ends before a comma

string nextString(string str, int start_index)

{

int i;

//find a comma or end of the string, after strat_index

for (i = start_index;i < str.length();i++)

{

//if comma is found, exit the loop

if (str.at(i) == ',')

break;

}

//extract the sub string

string out= str.substr(start_index, i-start_index);

return out;

}

//splits the comma separted string as individual strings

//and returns the number of individual strings

int split(string str, string a[], int max_size)

{

int i, j;

int start_index = 0;

//search for commas in the given string

for (i = 0,j=0;i < str.length();i++)

{

//if comma is identified or end of the string is identified

//, then get a strig that starts at start_index using next string

if (str.at(i) == ',' ||i==str.length()-1)

{

//save each string into an array of strings

a[j] = nextString(str, start_index);

//update the next string starting postion(starts after comma)

start_index = i + 1;

j++;

}

}

return j;

Explanation:

Please see attachments

You might be interested in
The _____ contains a series of sections designed to prepare students for the ACT
Studentka2010 [4]
The answer is aspire test 
3 0
3 years ago
Read 2 more answers
Difference between a software package and Integrated software and why users would choose one over the other
ivolga24 [154]

Answer:

Software Package means software which is used collectively, implements alike purposes, or combines alike characteristics and is bundled collectively being one kit from software applications, where as, Integrated software is a combination of software specifically built to operate on almost linked applications.

Explanation:

Users should choose Software Package because of the following reasons:

  • Cheap price compared over buying individual application independently.
  • Opportunity to introduce the total of the applications at the corresponding period or just that applications you require to work.
  • The compatible user interface of individual application over another.
  • The facility to distribute data among applications.
  • Coming updates can refresh every application whole by the corresponding event.
  • Perfect for individual use, licensed use, huge or little company.
  • Every software holds the full-featured transcription.
5 0
2 years ago
Does the sticker list an automatic or manual transmission?
pantera1 [17]
Automatic, three speed transmission
5 0
3 years ago
Read 2 more answers
| HELP PLS! C++ Sorting arrays can be performed using either Selection Sort or Insertion Sort or
Sholpan [36]

Answer:

wwhwwwwnlcw lcwl. wl w l. w la a. a. ac aa cw w w w. w. w. w w. ww w. w w w. w w w ww w w. w w ww. w cs s js jw jw kw kw ks jpsbp svkhs ksl oheo

8 0
2 years ago
Email Communication has it own set of etiquette guidelines for users to follow if they want to be effective communicators. Which
Olin [163]
You answer is most likely D.
5 0
2 years ago
Other questions:
  • How many times do you usually use npm?<br> Put your answer in the box.
    6·1 answer
  • Any malware software that covertly gathers user information without the user s knowledge, is known as ______ .
    12·1 answer
  • What is the purpose of the "time-to-live" (TTL) field of the IPv4 packet? a. ensures that the packet remains in the network long
    6·1 answer
  • Windows displays a(n)
    11·1 answer
  • System. Construct an ER diagram for keeping records for exam section of a college.​
    10·1 answer
  • Larry does not want to save his internet browsing details on his computer. What files should Larry delete to clear his informati
    13·2 answers
  • Calcula l'energia (Kwh) consumida per una màquina de 30 CV que funciona durant 2 hores.
    12·1 answer
  • 50 ) What is the cell address of 4th row and 4th column? A) 4D B) E4 оооо C) 04 D) B4​
    9·1 answer
  • 8. The cell reference for a range of cells that starts in cell A1 and goes over to column G and down to row 10 is, a. A1-G10 b.
    7·1 answer
  • Mack signs into his laptop and gets a message saying all his files have been encrypted and will only be released if he sends mon
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!