Topics: new, delete, string class
Read the style guide page. The requirements used with all assignments are specified there. There will be a lot of code in these assignments. Organizing it as specified in the style guide page will help to find things.
Write a program containing the following functions, in this order:
main - calls the other functions; otherwise does almost nothing
getSize - which asks the user how many strings they want
getSpace - which gets an array in the heap of the size requested by the user
inputData - which allows the user to input the strings and stores them in the array
printData - which prints all the strings, one string per line
destroy - which returns all the space to the heap
All of these functions, except main, shall have a return type of void.
Write ONE program containing all these string exercises.
Read a string from the user into a string named string1.
Test it with the data: Good morning
Print the following heading and the data contained in string1:
Create a new string named string2 containing the contents from string1.
Append the following text to the end of string 2.
(Note that there is a space before sleepy.)
Print the following heading and the data contained in string2:
Good morning sleepy heads
Create string3 with an initial value of:
bellow cello fellow hello mellow Novello Othello pillow Rollo solo yellow
Find the location of the first h in string3
Print the following heading and the location found in string3:
Create an empty string named string4.
Copy string3 into string4.
Using the location found in exercise 3,
change the first h into J
Print the following heading and the data contained in string4:
bellow cello fellow Jello mellow Novello Othello pillow Rollo solo yellow
Create a copy of string3 named string5.
Use the find_last_of member function to find the position of the last l
Print the following heading and the position of the last l
Create a new string named string6 containing the contents from string3.
Using the position of the last l found in exercise 5, erase all characters from string6 following the last l
Print the following heading and the data contained in string6:
bellow cello fellow hello mellow Novello Othello pillow Rollo solo yell