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
What is computer hadware​
Alex Ar [27]

Answer: like the monitor or the keyboard

Explanation: it is true i even looked it up and it was true

8 0
2 years ago
The security administrator of ABC needs to permit Internet traffic in the host 10.0.0.2 and UDP traffic in the host 10.0.0.3. Al
koban [17]

Answer:

The correct selection is the letter C. The first ACL is denying all TCP traffic and the other ACLs are being ignored by the router.

Explanation:

In this case, the letter C is the right answer because with the first ACL exactly:

access-list 102 deny tcp any any

We are denying all traffic with the next line deny tcp any any, in this case, the others line are being ignored.

access-list 104 permit udp host 10.0.0.3 any

access-list 110 permit tcp host 10.0.0.2 eq www any

access-list 108 permit tcp any eq ftp any

For that nobody can access to the internet, the security administrator of ABC must change the first ACL.

5 0
3 years ago
Which is the fastest method of sharing public folders?
Rasek [7]

Answer:

I'm stuck on this but the correct answers I would at-least pick is A and C I need more information about what operating system you have on the computer.

3 0
3 years ago
To change from psig to psia, you must
EastWind [94]

Answer:

You must add atmospheric pressure

Explanation:

The unit for gauge pressure is PSIA. You convert between them by adding or subtracting atmospheric pressure. 1 PSIG = 1 PSIA - atm and conversely: 1 PSIA = 1 PSIG + atm.

3 0
2 years ago
Which concept allows the computer to repeat a group of steps in an
allochka39001 [22]

Answer:

A

Explanation:

I was gonna say 'loop' from my computing days. but it is now called iteration

7 0
1 year ago
Other questions:
  • What is output when the CarTest application is run? Why?
    11·1 answer
  • Which answer choice correctly distinguishes among the three pieces of data?
    13·1 answer
  • Which button could Pamela press in the Microsoft Word spell checker to make the word “colour” instantly change to “color” whenev
    11·1 answer
  • The following loop is intended to print the numbers 1, 2, 3, 4, 5.
    11·1 answer
  • Did you know a security hacker is someone who explores methods for breaching defenses and exploiting weaknesses in a computer sy
    11·2 answers
  • What is business agility
    7·2 answers
  • Web résumés allow you to include extra graphics and images that you would not include in a traditional résumé. please select the
    13·1 answer
  • CS902 Module3 Homework1
    11·1 answer
  • When evaluating an AND operator, what is necessary for execution?
    7·1 answer
  • If a robot is able to change its own trajectory as per the external conditions, then the robot is considered as the__.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!