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?
%Lf
conversion specifier is forlong double
, not fordouble
,%lf
is fordouble
. – Daniel Fischer%Lf
is forlong double
not plaindouble
. With Microsoft compilers, long double is the same size as double but other compilers have extended-size long doubles. I have no idea what's gone wrong with the int, unless id is in fact a long and you have a 32-bit/64-bit mismatch? – Alan Curryfscanf()
so you know how many conversions worked? Iffscanf()
does not report 4, you've got a problem. Was the other compilergcc
? If so, what did it tell you when you enabled warnings with-Wall
? – Jonathan Leffler