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
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
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