Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here are the three functions that are implemented in the code below: void get_string(string &str_to_store); void set_replace_string(string copy_str, string &dash_str); int get_search_replace(char c, string copy_str,

Here are the three functions that are implemented in the code below:

void get_string(string &str_to_store); void set_replace_string(string copy_str, string &dash_str); int get_search_replace(char c, string copy_str, string &dash_str); 

1a. Please change the prototypes in the code below to (Do not change the purpose of each function, modify the program so it works with the updated prototypes):

void get_string(string *str_to_store); void set_replace_string(string copy_str, string *dash_str); int get_search_replace(char c, string copy_str, string *dash_str); 

1b. Please explain what has been passed into these pointer variables, and tell the difference between pass by reference and pass by pointers.

#include using namespace std;

void get_string(string& str_to_store); void set_replace_string(string copy_str, string& dash_str); int get_search_replace(char c, string copy_str, string& dash_str);

int main(){ string str_to_store, dash_str; char c; int count; get_string(str_to_store); set_replace_string(str_to_store,dash_str);

cout<<"Dash string : " << dash_str << endl; cout<<"Enter a character to search : "; cin >> c; cin.ignore(1024,' '); count = get_search_replace(c,str_to_store,dash_str); cout<<"Updated dash string: " << dash_str<

return 0; }

void get_string(string& str_to_store){ cout<<"Enter a string : "; getline(cin, str_to_store,' '); } void set_replace_string(string copy_str, string& dash_str){ dash_str =""; for(int i=0; i

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

Step: 3

blur-text-image

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

What behaviors are discouraged?

Answered: 1 week ago