I have a function
void getXFromFile3(FILE* fptr){ double valueX; fscanf(fptr, "%lf\n", &valueX); printf("%lf", valueX); } and file data.dat with some double numbers.
One of them is -0.572869279, but my function print -0.572869. It looks like somewhere my number was cut off.
Any ideas what I am doing wrong?
printf("%.9lf", valueX);(or more) because the default is 6 places.doubleswith different lengths after the decimal. We wouldn't want to print the extra zeros ( probably not the case here) and also what if it has greater than 9 digits sayxdigits? What then?%sand store that as well as processing withsscanf. The answer was: Nothing wrong, the number read is not being cut off.xplaces useprintf("%.*lf", x, valueX);This is a non-question - it's all in theprintfman page.