In a C++ code I have a matrix of double variables which I print out. However because all of them have different number of digits, the output format is destroyed. One solutio
Take a look at stream manipulators, especially std::setw and std::setfill.
float f = 3.1415926535;
std::cout << std::setprecision(5) // precision of floating point output
<< std::setfill(' ') // character used to fill the column
<< std::setw(20) // width of column
<< f << '\n'; // your number