I have a problem with the following code .....
FILE* out_file;
out_file = fopen("c:\\data.dat", "w");
double data = 0.017876148;
.....
fprintf(out_file,"%lf", data);
fclose(out_file)
I want to print out the exact 9 digits on a dat/txt file but I am getting a truncated digit of 0.0178761. How can I fprintf the whole data without being truncated ?
C code help for file output?
with the printf field modifier, like so ...
fprintf(out_file,"%.9lf", data);
see the '.9' ? that says to use nine digits of precision after the floating point....good luck
Man I love C. Hope you can enjoy it too. It's a steep learning curve at first, but very powerful lang and worth the work. Can't tell you how many languages borrowed and stole C ideas and structure. My point: learning C will aid leaning across many languages...no time is spent on it is lost, so to speak.
Reply:Anytime, like to help. Very welcome.... Report It
violet
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment