Reputation: 21
Here is my code. I tried all the different ways with left << setw(20)
but it does not show me the proper outcome.
void MotorVehicle::moveTo(const char* address)
{
if (strcmp(Address, address) != 0)
{
cout << "|" << setw(10) << PlateNumber << "| |" << setw(20) << Address << " --->--- ";
cout << address << "|" << endl;
strcpy(Address, address);
}
}
Hi guys this is the expected out put.
| T-1111| | Montreal --->--- New York |
| T-1111| | New York --->--- New Jersey |
| T-1111| | New Jersey --->--- Toronto |
Upvotes: 0
Views: 66
Reputation: 3676
Remember setw
is not 'sticky'. It only applies to the subsequent output field. All other manipulators apply until the are superseded.
Thus I think you want:
cout << setw(20) << left << address << "|" << endl;
Upvotes: 2