Hello, I have a text file with three values.
2.5 7.6 -3
I am trying to output the values in another text file, with a decimal point of 5 places. I have done this before with cout, however I am having trouble implementing it to fout. Below is me trying to do it similar to cout.
ofstream fout("roots.txt");
fout << setprecision(5);
fout << "The equation " << setprecision(5) << a << "x^2 + " << setprecision(5) << b << "x + " << setprecision(5) << c << " has roots " << root1 << " and " << root2 << endl;
fout.close();
You will probably also want to use std::fixed and possibly std::showpoint along with std::setprecision(), and note that these manipulators are "sticky" (meaning that they will stay in effect until changed) and only need to be done once.