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 ? What is computer program? What is hard disk.
g100num [7]
A computer is a electronic that helps you access the internet/WiFi
4 0
3 years ago
Read 2 more answers
Write any two rule of function​
Morgarella [4.7K]

Answer:

Begin to write the function rule by placing b on one side of an equal sign. Step 2 Look at the first row of the table. Think about how the input value and the output value are related. There are two ways to get an output value of 1 when the input value is 2.

Explanation:

Plz Mark me as brainliest

3 0
3 years ago
Design a program using ordinary pipes in which one process sends a string message to a second process, and the second process re
Dmitry [639]

Here's a solution in C#. Create two console applications, one for the client and one for the server. In the server, put this:

           Console.WriteLine("Listening to pipe...");

           var server = new NamedPipeServerStream("BrainlyPipe");

           server.WaitForConnection();

           var reader = new StreamReader(server);

           var writer = new StreamWriter(server);

           while (true)

           {

               var line = reader.ReadLine();

               if (!server.IsConnected) break;

               Console.WriteLine("Received: " + line);

               writer.WriteLine(ChangeCase(line));

               writer.Flush();

           }

To change case, add this function:

       public static string ChangeCase( string s)

       {

           var sb = new StringBuilder();

           foreach(char c in s)

               sb.Append(char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c));

           return sb.ToString();

       }

In the client, put this:

           var client = new NamedPipeClientStream("BrainlyPipe");

           client.Connect();

           var reader = new StreamReader(client);

           var writer = new StreamWriter(client);

           writer.WriteLine("Brainly question 13806153 demo");

           writer.Flush();

           Console.WriteLine(reader.ReadLine());

           Console.ReadLine();


5 0
3 years ago
The audience, setting, and type of presentation help determine presentation content. True or False?
WARRIOR [948]

True. The audience is the key to the style of presentation and the content is led by the key to the topic. If the setting blends well with the audience age, gender, background, the presentation will be more effectively presented and positive, which will be more helpful to sell the audience to the point that is being made by the presenter.

6 0
3 years ago
The _________ attack exploits the common use of a modular exponentiation algorithm in RSA encryption and decryption, but can be
coldgirl [10]

Answer:

The answer is "timing".

Explanation:

  • The time attack would be a security vulnerability that enables attackers that identify computer systems or network security issues by analyzing the period of the program's reaction to multiple levels.  
  • It is used in both RSA encryption and decryption of the modular exponentiation method but could be modified for just about any system not seem running in a fixed period.
6 0
3 years ago
Other questions:
  • What is Blender's default save directory for movie AVI files?
    9·2 answers
  • Test Average and Grade
    12·1 answer
  • Troubleshooting a printer that does not work includes a. connecting the printer to your computer b. checking to see if there is
    13·1 answer
  • _____ is a systems development technique that produces a graphical representation of a concept or process that systems developer
    11·1 answer
  • Java public class Odds { public static void main(String[] args) { printOdds(3); printOdds(17/2); int x = 25; printOdds(37 – x +1
    12·1 answer
  • '|'/2`/ '|'[] |)[-([]|)[- '|'#!$
    9·1 answer
  • How many grams are in 100 pounds?
    6·2 answers
  • Why can it be helpful to perform mathematical calculations using programming? Choose the best answer.
    11·1 answer
  • (Correct Answer Recieves Brainliest)
    8·2 answers
  • What sound customization option would you use in Scratch to simulate a sound happening in a large, empty room (like a theater)?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!