Formatting text input

this is what i have to do, i have an idea on how to do it but the c++ book does little to explain on what the task asks. They gave a skeleton of the code but its still confusing me. Can anyone explain on how i would get this code started?


* Write a function myformat() that formats text files so that most lines contain approximately
* "length" characters. Start with the preprocessing directive
*
* #define MAX_LENGTH 70
*
* Then, read in an integer to a variable length in main(), and pass it to reformat() as an
* argument. Make sure the integer value that the use entered is in the range greater than zero
* and less than MAX_LENGTH.
*
* Use file I/O (read in from an input file and write out to an output file). Prepare the file
* stream objects in main() and pass them to reformat() as arguments.
*
* In the function reformat(), count the characters as they are written. As long as count is less
* than length, change any newline character to a space. When the count is "length" or more, write
* any white space character as a newline and reset the count to zero. If we assume that most
* words contain fewer than 10 characters, then the effect of the program is to write lines
* containing between "length" and "length+10" characters. The function returns the total number
* of lines that have been written to the output file, which main() outputs to the screen.
Last edited on
Open your editor. Press keys.

Start with the preprocessing directive
#define MAX_LENGTH 70


the # can be generated by pressing the shift and 3 key at the same time.

Seriously, what you need to do is pretty much completely spelled out for you. Bite the bullet and start coding. If you run into a snag, give us a holler.
Topic archived. No new replies allowed.