C++ Word Wrap внутри столбца

Мне нужно вывести некоторые столбцы в C++, которые выглядят так:

          Lower  Upper
   Line   case   case   Digits Spaces Other
   ------ ------ ------ ------ ------ ------

Чтобы распечатать некоторые результаты из файла чтения и т. Д., И т. Д.

Есть ли в любом случае, чтобы сделать перенос слов в C++ с помощью setw(6)???

Мой код выглядит так:

   #include <iostream>
   #include <iomanip>

   using namespace std;

   void printLines(); // declaring

   int main(int argc, char *argv[]) {

          // print table headings
      cout << setw(6) << "Line" << setw(1) << " ";
      cout << setw(6) << "Lower case" << setw(1) << " ";
      cout << setw(6) << "Upper case" << setw(1) << " ";
      cout << setw(6) << "Digits" << setw(1) << " ";
      cout << setw(6) << "Spaces" << setw(1) << " ";
      cout << setw(6) << "Other" << endl;

       printLines();


   };

   // function to output 5 "lines" to divide the table headings from the data

   void printLines() {

       for (int i = 0; i < 6; i++) {

           cout << setfill('-') << setw(6); // set output fill
           cout << "-" << setfill(' ') << setw(1) << " ";

       };

       return;

   };

Но мой вывод выглядит так:

  Line Lower case Upper case Digits Spaces  Other
------ ------ ------ ------ ------ ------ 

Какие-либо предложения? Благодарю.

0 ответов

Другие вопросы по тегам