Hasan Karaman Hasan Karaman - 9 months ago 67
C++ Question

How do i set precision of output file?

ofstream coord("C:\\coordinates.txt");
(for loop starts here)
(things happen here)
coord << i << "," << result[i].X << "," << result[i].Y << ",0\n";
(for loop ends here)

ladies and gentlemen , in the output file i'm having coordinates exponential like this:


how can i get rid of those exponential parts? i tried to put a "fixed" after "coord<<" in the line below but it didn't work.

coord << i << "," << result[i].X << "," << result[i].Y << ",0\n";

thanks in advance.


Use std::fixed

std::cout << std::fixed << result[i].X