The following line of code is supposed to read a string, an int and two doubles separated by commas and store them in variables.
fscanf(f,"%[^,],%d,%Lf,%Lf",name,&id,&east, &north);
It works on my Visual Studio 2010 compiler and reads the right values. I’ve run the program on another machine on which I’ve got random values for the three numbers but the right value for the string.
What could it be?
%Lfis for typelong double, notdouble. On Microsoft compilers,long doublehas the same size and representation asdouble, so it happens to work, but your code is nonetheless invoking undefined behavior by using a mismatching format specifier. Use%lfwithdouble, or change the type tolong doubleif you want to use%Lf, and it should work everywhere.