print double precision

Suppose , I have double float a= 40.2 and a pointer to a file
I want to print it in the file as 40.20 .

I've tried this :

1
2
3
logfile new std::ofstream;
logfile -> open(filename, std::ios::app);
 *logfile << a

but it gives 40.2 as output!

any suggestions?

thank you very much!
http://www.cplusplus.com/reference/iomanip/setprecision/
http://www.cplusplus.com/reference/ios/fixed/


> a pointer to a file
¿why a pointer? ¿why created with new?
std::ofstream logfile(filename, std::ios::app);
Why do you always quote with an upside down question mark?

Just curious..
¿ah? I quote with a waka `>'
It's easier than using the [quote][/quote] tags, and I like the result better (especially when nesting)


If you refer to why I prefix the questions with an interrogation mark
http://www.cplusplus.com/forum/lounge/113988/5/#msg635112
I see... thanks :)
Topic archived. No new replies allowed.