cout<<" Name\t"
<<"Cat\t"
<<"Barcode\t"
<<"Price\t"
<<"Manufa\t"
<<"Stock\t"
<<"Sold\t"
<<"ExDate\t "
<<"Disc"<<endl;
for (unsigned int i=0; i < _storage.size(); i++)
{
cout <<i <<":";
_storage[i]->showData();
cout<<endl;
}
I am trying to display data in a aligned manner.I am currently using the `t` character to do this but this will result in a misalignment if the data in one of the variable is too long.
How do I properly display data in a table form in C++?
you can use setfill
and setw
to set the fill char and width of the columns. The problem is you are going to have to limit the columns for it to look right.