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

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!