Question
1. For this assignment you will: a. Create a solution with a console application project containing a single .cpp file detailed in (2) below. b.
1. For this assignment you will:
a. Create a solution with a console application project containing a single .cpp file detailed in (2) below.
b. Write two functions concerning string handling, detailed in (3) below.
c. Implement a main function that tests these function as detailed in (4) below.
2. Create a Visual Studio Solution/Project:
a. Select File New Empty Project and give the solution and project a name/location.
b. Right-click on the project and select Add New Item. Add a new C++ File (.cpp ). This will contain your main function. Make sure you include and .
c. Right-click on the project again and select Properties
d. Change the Configuration Type setting to Application (if not already)
e. Make any other project settings changes post-project-creation (I will cover these in class).
3. In the .cpp file, implement two functions that perform the following:
a. Write a function named trim that takes a string and removes any whitespace from the end of it. The signature should be something like void trim(std::string& s); Note this is an in-place trim (i.e. the string passed in will be modified by side-effect to hold the result)
b. Write a function named parenthetical with the following signature std::string parenthetical(const std::string& s); This function will return any text in the given string between an open parenthesis,(, and a closing parenthesis, ), returning the empty string if no such test exists.
c. Try to take into account mismatched and unordered parentheses.
4. In the .cpp file:
a. Create a main that calls the trim function with a few of the strings that may or may not need trimming, printing out each string after each call. Some test cases are
Data Result Reason No content, let alone any spaces look no spaces look no spaces No spaces to trim spaces on the end spaces on the end Removes trailing spaces on the front now on the front now Removes leading spaces both, now both, now Removes both leading and trailing
b. Call the parenthetical function with a few strings, some of which have parentheticals and some of which do not. Some test cases are
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started