My function to display a division table is working, but I want to format the output to allow any number of character preceding the decimal, but limiting the after decimal places to 2. Here is the code I am working with. Once I added the line cout.setf(std::ios::fixed, std::ios::floatfield) my data appears to be formatted correctly, but I am getting extra numbers appended to the front of the actual number.
so instead of printing 1.00, the program prints 40981.00, and it does this for all the results. (the preceding number does change to 4102x.xx) x being the desired output.
void print_div_values(mult_div_values ** table, float x, float y){
cout << endl << "Here is the division table: " << endl;
for (int i = 1; i <= y; i++)
{
cout << endl;
for (int j = 1; j <= x; j++)
{
cout << std::setw(5) << cout.setf(std::ios::fixed, std::ios::floatfield) << std::setprecision(2) << table[i][j].div;
}
cout << endl;
}
