for (int car = 0; car < maxCars; car++)
{
cout << "Car " << car+1 << ": Enter Time in Hours or 0 to exit " ;
cin >> time[car];
if (time <= 0)
{
return 0;
}
I have an idea. Store what you want to "cout" into a string. That way, you can access its size. Then use that, with some spaces, to put your columns into place.
For example:
#include <iostream>
#include <string>
usingnamespace std;
//function to print certain number of spaces
void putspace(int spc){
for (int i = 0; i<spc; i++){
cout << " ";}}
//how far over we want our column to be
constint WIDTH = 50;
int main(){
//output string
string output = "row1";
//insert output, then the number of spaces required to get to 100, then the column
cout << output;
putspace(WIDTH - output.size());
cout << "Even column1" << endl;
//change output
output = "row2";
//same
cout << output;
putspace(WIDTH - output.size());
cout << "Even column2" << endl;
/*
whatever you prefer to stop the program
people get REALLY aggressive over the "proper" way to do this,
so i will leave it blank
*/
return 0;}