Question: Your team is tasked to write a program that operates on a std::string of text (assume there are no line breaks in it) and insert

Your team is tasked to write a program that operates on a std::string of text (assume there are no line breaks in it) and insert linebreaks such that no more than a specified number of characters of text occur per line. You should not split up words across lines, so there maybe less than that specified number of characters of text per line. For instance, if the specified number of characters was 30, the

std::string of text Alice opened the door and found that it led into a small passage, not much larger than a rat-hole: she knelt down and looked along the passage into the loveliest garden you ever saw. would be stored in a new std::string, with the necessary line breaks, as Alice opened the door and found that it led into a small passage, not much larger than a rat-hole: she knelt down and looked along the passage into the loveliest garden you ever saw. and written to standard output accordingly.

-Implement a program in C++ that meets the specifications detailed above. Make sure that you compile frequently on and test diligently.It is recommended that you use stringstream (#include) in your solution; you dont have too though, but Id recommend getting some practice with stringstreams prior to the exam.

Note: provided an output stringstream ostringstream oss you could insert a value to that string using the familiar oss << word notation. Once youve inserted everything necessary to the stream, you can create a string from the stream by writing oss.str().

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!