Hasan Karaman Hasan Karaman - 1 year ago 98
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.

Answer Source

Use std::fixed

std::cout << std::fixed << result[i].X
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download