How do I display this table in the console?

os << dt.year << "." << dt.month << '/' << dt.day << dt.name << dt.surname << dt.discplace << dt.wayplace << endl; return os; 
  • and you take and read about the possibilities of the class std :: ostream, as well as manipulators - such as std :: setw .... - AR Hovsepyan
  • and if you get tired of this unreadable super-long madness and want an adequate format line in the style of C or python, then I sympathize, in the standard it is not; and hardly the only solution is boost::format . If the dependency on boost is not an option, then it will be easier to use the usual C'shny *printf() . - Fat-Zer
  • @ Fat-Zer Well, why is there no standard? printf is a standard C ++ library function ... - Harry
  • @Harry, while I was not stoned, I beg forgiveness for mentioning the sacred Standard in this;) - Fat-Zer
  • one
    @ Fat-Zer Not with stones, but with monolithic structures :) - Harry

1 answer 1

Connect the iomanip library and output

 cout << setw(8) << dt.year << "|" << setw(6) << dt.month << "|" и т.д 

setw () sets how much space will be allocated for the value output