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
Once Raul selects a technology solution, he has completed the process. <br> a. True<br> b. False
romanna [79]
The answer is true because choosing a technology solution is the last step
7 0
3 years ago
Read 2 more answers
On tool hackers use to get sensitive information from victims is/are:
Feliz [49]
Pretty sure it’s keyloggers because it’s the only one that makes sense to me but I’m not 100% sure on that one
5 0
3 years ago
Read 2 more answers
Mike needs to write the primary objectives of a project in a project plan. In which section should he write them?
Advocard [28]

Mike needs to write the primary objectives of a project in a project plan. He should write this under the SCOPE section of the project plan.

Explanation:

  • Project scope is the part of project planning that involves determining and documenting a list of specific project goals, deliverables, features, functions, tasks, deadlines, and ultimately costs.
  • It is what needs to be achieved and the work that must be done to deliver a project.
  • The Scope of Work (SOW) is the area in an agreement where the work to be performed is described.
  • The SOW should contain any milestones, reports, deliverables, and end products that are expected to be provided by the performing party. The SOW should also contain a time line for all deliverables.
  • The scope is simply all the work that needs to be done in order to achieve a projects objectives.
  • A project scope, or project scope statement, is a tool used to describe the major deliverables of a project including the key milestones, high level requirements, assumptions, and constraints.

7 0
3 years ago
Sandie is writing a report for her environmental science class. She has asked her older sister who is away at college to proof h
vichka [17]
Help each other because if the other sister is older she should have more experience and knowledge

8 0
3 years ago
Read 2 more answers
Select the correct answer from each drop-down menu.
xz_007 [3.2K]

Answer:

Maths operators

cell reference

5 0
2 years ago
Other questions:
  • Consider the following scheduling problem. You are given a list of final exams F1,...,Fk tobescheduled,andalistofstudentsS1,...,
    10·1 answer
  • What type of printer heats toner to adhere it to the paper? inkjet . impact. 3D. laser.
    6·1 answer
  • Create a structure named planet This structure will contain distance from Earth as an integer Atmosphere, language, people and p
    8·1 answer
  • Web and mobile applications are created for users to only read information. True False
    15·2 answers
  • List the steps in setting up an online banking account
    12·2 answers
  • How much time per day does the average U.S. youth spend watching television, playing video games, or using a computer?
    8·1 answer
  • During which geologic era was nearly all of Earth's land concentrated into one giant mass called Pangaea?
    6·1 answer
  • Where does the turtle belong in the cladogram shown below?<br> I’LL GIVE YOU BRAINLYEST
    6·2 answers
  • Write a method doubleUp that doubles the size of a list of integers by doubling-up each element in the list. Assume there's enou
    13·1 answer
  • What is the difference between a general ai as opposed to a specialized ai?.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!