Jane Smith 100
Rose Diaz 200
John Williams 150
Felicia Johnson 250
Ron Davis 75
I am trying to output that file into another file using arrays but it never lines up correctly. This is how it always ends up looking like.
Any advice?
Jane Smith 100.00
Rose Diaz 200.00
John Williams 150.00
Felicia Johnson 250.00
Ron Davis 75.00
1 2 3 4 5 6 7 8 9 10
void SalesReport(string outputfilename, string firstname[], string lastname[], double Sales[], int ArraySize)//missing parameters
{
ofstream OutputFile; //sets output data file varible
OutputFile.open(outputfilename); //sets name for output variable
for (int i = 0; i <= 4; i++)
{
OutputFile << fixed << setprecision(2);
OutputFile << firstname[i] << setw(15) << lastname[i] << setw(20) << Sales[i] << "\n";//trying to set up data from inputfile to read out onto file
}
}
Thank you for your advice. I tried putting left into my code and setw before the first name like you showed and it worked. I am kinda struggling to understand how it fixed it but ill just have to do more research, Thankyou.
SOLUTION
1 2 3 4 5 6 7 8 9 10
void SalesReport(string outputfilename, string firstname[], string lastname[], double Sales[], int ArraySize)//missing parameters
{
ofstream OutputFile; //sets output data file varible
OutputFile.open(outputfilename); //sets name for output variable
for (int i = 0; i <= 4; i++)
{
OutputFile << fixed << setprecision(2);
OutputFile << left << setw(15) << firstname[i] << setw(15) << lastname[i] << setw(20) << Sales[i] << "\n";//trying to set up data from inputfile to read out onto file
}
}
Jane Smith 100.00
Rose Diaz 200.00
John Williams 150.00
Felicia Johnson 250.00
Ron Davis 75.00
Actually i switched it to Right instead of left and setw(7) and it looks even better
1 2 3 4 5 6 7 8 9 10
void SalesReport(string outputfilename, string firstname[], string lastname[], double Sales[], int ArraySize)//missing parameters
{
ofstream OutputFile; //sets output data file varible
OutputFile.open(outputfilename); //sets name for output variable
for (int i = 0; i <= 4; i++)
{
OutputFile << fixed << setprecision(2);
OutputFile << right << setw(7) << firstname[i] << setw(15) << lastname[i] << setw(20) << Sales[i] << "\n";//trying to set up data from inputfile to read out onto file
}
}
Jane Smith 100.00
Rose Diaz 200.00
John Williams 150.00
Felicia Johnson 250.00
Ron Davis 75.00