I have the comma as the decimal separator in my Windows regional settings (Portuguese language), and all the programs I develop use the comma when formatting strings or using atof
.
However, this particular program that came into my hands insists on using the dot as the decimal separator, regardless of my regional settings.
I'm not calling setlocale
anywhere in the program or any other language changing function AFAIK. In fact I put these lines of code at the very beginning of the InitInstance()
function:
double var = atof("4,87");
TRACE("%f", fDecimal);
This yields 4.000000
in this program and 4,870000
in every other one.
I figure there must be some misplaced setting in the project's properties, but I don't know what it is. Anyone can help?
I'm not calling setlocale anywhere in the program or any other language changing function AFAIK.
That'd be why. C and C++ default to the "C" locale. Try setting the locale to "": setlocale(LC_ALL,"");