Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I have posted the question and what my code looks like now #include #include #include #include #include mystring.h using namespace std; int main(int argc, int
I have posted the question and what my code looks like now
#include
int main(int argc, int argv[]) { //Get user input and output information int numCols; cout > numCols; cout
ifstream file("data.txt"); string myStr;
//Get string size string temp; while (file >> myStr) { cout
} else if (mystrglength + templength > numCols) { int num= numCols -(templength)-1; for (int i = 1; i
} } } else { }
}
return 0; }
Here is the complete implementation of mystring.h and mystring.cpp. This is similar to STL string, but it does not include all features available from STL string. For the educational purpose, we focus on using our own implementation of various string data structures and functions. Take a close look at each function, how dynamic arrays are handled, and how operator overloadings for various functions are implemented. Using the mystring.h and mystring.cpp, (you're not supposed to use STL string for this homework) 1) implement a text file formatting program. It takes a text file data.txt as an input file. The file name can be hard-coded in your program or take a file name as a command line parameter. The file has a few lines of text but the length(column) of the line is arbitrary. One line could have anywhere between 1 to 200 characters before a new line (carriage return). Your program should ask the number of column to the user and format the text file accordingly. For example, if a user types 65, every line should be aligned 65 long. You may have to combine two lines to one to eliminate the white spaces and blank lines, or split one to two. 2) in cases you need to change line in the middle of a word, you need to use a hyphen to connect a word between two lines. 3) There should be no more than one white space between two words. Multiple spaces, newlines or tabs must be replaced with a space. You can assume that a hyphen can be added after the maximum column. So if you're formatting a text to 60 columns and a word is starting at the 60th column, you can add hyphen at 61st. Only the hyphen can come at 61st. For the output, display the formatted text on screen and save it to data.out file. Hint: You may find eat_white function in mystring useful for removing white spaces. This link has a comprehensive description of allStep 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