#ifndef _PRINT_WITH_WRAP_ #define _PRINT_WITH_WRAP_ #include #include #include using namespace std; /* * Robert Sloan, October 2002, for Fall 2002 CS 202 course. Loosely * after a Stanford U. CS Dept. C function for a similar assignment. * * PrintWithWrap * ------------- * This internally tracks how many characters are on the current line and * when getting to close to the end, finds a convenient space character * and turns it into a newline to get new line-wrapping output. Each * call continues in the place the previous call was unless the second * argument is the bool true asking for a reset, in which case a * carriage return is output and printing resumes at the far left. * The place of the wrap can be adjusted with the third argument (in which * case all 3 agruments must be given). * Note that when all done with calls to PrintWithWrap the cursor will * generally be in the middle of the last line printed, so the caller * may wish to either output an endl or end with a string ending in \n. */ void PrintWithWrap(const string& longString, bool reset = false, int wrap_at_column = 65); #endif