I am currently debugging code that sometimes works and sometimes does not.
It is an OBJ file loader and I found the part that makes problems:
double val = strtod(str, &endptr);
To explain the problem I will give you an example of the values after strtod was called.
str = "-0.021344"
val = -0
*endptr = '.'
Behind that line error checking is done and if *endptr != '\0' an error is thrown.
Now of course an error is thrown because strtod marked the dot as the end of the number,
but why is this so? Also note that I only encounter this error when using the code in QT projects.
Thanks for your ideas.
Maybe you’re using a locale for which the decimal point is not
.. Trysetlocale(LC_NUMERIC, "C");before thestrtodstatement.Note: I don’t know how locale and QT behave together. You may want to save and restore the locale …