I am trying to get double values from file using fscanf function.
I am running the following code:
this is extract from my code:
double some_double;
fscanf(file_name,"%lf", &some_double);
for ex. content of file is “10.5”
in debug mode, I see that was read value == 10.0000
What is it: bad implementation of fscanf function, or my mistake?
If second variant – please advice how to fix it?
Kindely thnx
Edit
#define nameOfFile "infoOnObjects.txt"
#define stop _asm nop
FILE* file = fopen(nameOfFile, "r");
if (file == NULL)
throw "error";
double num;
int n = fscanf(file,"%lf", &num);
Check if your locale symbol for decimal divisor is point ‘.’, not comma ‘,’. This issue is valid on some platforms (Ubuntu gcc, for example; while on Windows mingw it doesn’t matters).