i have following part of code:
string v;
getline(linestream,v,' ');
double d=atof(v.c_str());
fprintf(writeFile3,"%f\n",(double)d);
but lets say first line has value 0.08012901 but d=0.080129 last 2 values are omitted, how can i get full double value?
Thank you
It's not that the decimal places are not stored in the
d
. It's just thatfprintf
only prints 6 decimal places by default. To print 8, tryYou don't have to cast
d
as adouble
since it already is of typedouble
.