Brock T.

asked • 02/09/22

Please Help C++

String Trim1

Write a function stringTrim that removes the first and last characters from a given string. "chello" should become "hell". 


Your function must work correctly given the code in main shown below. Examine it to decide if you should return the new value or use a reference parameter.

int main()
{
string word = "bob";
stringTrim(word);
cout << word << endl;
}

Code:


#include <iostream>

#include <string>

using namespace std;

//Do not modify anything on or above the line below this

//YOUR_CODE_BELOW


//YOUR_FUNCTION HERE


//YOUR_CODE_ABOVE

//Do not modify anything on or below the line above this


int main()

{

string word;

cin >> word;

stringTrim(word);

cout << word<< endl;


}


1 Expert Answer

By:

Caleb P. answered • 02/14/22

Tutor
4.9 (53)

Software Programmer and Game Developer

Dat K.

you cannot modify anything in the int main ()
Report

05/02/22

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.