I think this is what you were trying to do...
Code:#include <iostream> #include <string> using std::cout; using std::cin; using std::string; using std::endl; int main() { const int max_column = 40, max_row = 10; string phrase = "This is a test phrase"; for (int row = 0; row < max_row; ++row) { int column = 0; while (column < max_column) { if (row == 0 || row == max_row - 1 ) { cout << "-"; } else { if (column == 0 || column == max_column - 1 ) { cout << "|"; } else { if ( row == 8 && column == 21 ) { while ( column + phrase.size() > max_column ) { string::size_type over_flow = max_column - column - 1; phrase.erase(over_flow); } cout << phrase; column = max_column - 2; } else { cout << " "; } } } ++column; } cout << endl; } cout << endl; system("PAUSE"); return 0; }




Reply With Quote