Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

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

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 all functions. Refer to cstring functions to get a clear understanding of operations. You may use appropriate and equivalent functions from mystring.h or from cstring.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions