I'm making a sales receipt. The user enters in the name and price of the items. On the display, I want the name of the items to be aligned as well as the price of the items. Is there a way to get the setw for the objects after the name to be determined based on the name length? Since the names of the items will be of different lengths. The specific part of the codde is below.
cout << "********************************************" << endl;
cout << "******** S A L E S R E C E I P T ********" << endl;
cout << "********************************************" << endl;
cout << "** **" << endl;
cout << "** **" << endl;
for (i=0; i<items; i++)
{
cout << "** " << name[i] << setw(3) << ": $" << setw(9) << price[i] << " **" << endl;
}//end for
cout << "** **" << endl;
cout << "** **" << endl;
cout << "********************************************" << endl;