Question
C++: Write a program that is composed of the following functions: 1. void clean(string& s); // This function keeps alphabets, digits, white spaces and any
C++:
Write a program that is composed of the following functions: 1. void clean(string& s); // This function keeps alphabets, digits, white spaces and any of the characters in ".,;!?-/()", and removes all other characters. It also removes any extra spaces; allows at most one space between words.
2. void capitalize(string& s); It capitalizes the first letter of every word. A word is recognized if it starts at index 0 of the line, or preceded by a non-alphabet character.
3. string split(string& s); It splits the string into two strings if the size of the original string is greater than 80. The returned string should start at index 0 of s with a size that is less than 81 such that the split does not occur in the middle of a word. The rest of the original string s overwrites the string s. If the size of the original string is less than 81, the function returns a copy of s and sets s to empty string.
4. int main(); Opens the file Text.txt for reading. For each line in the file, it does the following: Calls the function clean Calls the function capitalize Calls the function split as many times as needed (as long as s is not empty) and saves the returned strings sequentially in the file output.txt.
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