mercredi 26 octobre 2016

read the data from file (precision to 20 places) in C

My text file which needs to be read is in following format (data.dat) -

0.001505882352941
34.900000000000018
121.800000000000010

i want to assign the following values to given buffer which is of type float and constraint is that i cannot change the data type of buffer

 fprintf(file_ptr, "%f", &buffer); 

i tried other methods also

double val;  
fprintf(file_ptr,"%lf", &val);
buffer = (float *) val;

but i am not getting proper values
i am running this program on cygwin window

values after decimal is always constant in number till 15 places

Aucun commentaire:

Enregistrer un commentaire