ansi-c fscanf problem
Posted
by mongoose
on Stack Overflow
See other posts from Stack Overflow
or by mongoose
Published on 2010-03-14T07:20:27Z
Indexed on
2010/03/14
7:25 UTC
Read the original article
Hit count: 517
hi i read the file as follows
fscanf(fp,"%f %f %f",&*(p1+i), &*(p2+i), &*(p3+i));
my file's lines consists of three floating point numbers...
the problem i have is that in the file let's say i have some floating points with let's say maximum of two digits after the dot. but when i ask c to print those values using different formatting, for example %lf,%.2lf,%.4lf... it starts to play with the digits... my only concern is this, if i have let's say 1343.23 in the file, then will c use this value exactly as it is in computations or it will play with the digits after the dot. if it will play, then how is it possible to make it so that it uses floating point numbers exactly as they are? for example in last case even if i ask it to print that value using %.10lf i would expect it to print only 1343.2300000000.? thanks a lot!
© Stack Overflow or respective owner