My text file which needs to be read is in following format (data.dat) -
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);
buffer = (float *) val;
which is of type float and constraint is that i cannot change the data type of buffer
Then you've got a problem.
values after decimal is always constant in number till 15 places
That's about the number of significant digits a double precision float can hold. There are 53 bits available for the mantissa in a IEEE 754 double precision floating point value. That gives you log10(2^53) = 15.95 decimal digits of precision (round that down to 15). That's what it can hold.
If you need higher precision you must use a different data type possibly combined with using a multiprecision math library.