If you encounter problems at runtime with the C library character handling functions from ctype.h,
e.g. isdigit(), toupper(), tolower()
or string conversion functions from stdlib.h,
e.g. atoi(), atof()
or string i/o functions,
e.g. sscanf() and sprintf()
this normally arises because the locale has not been correctly initialized or it is being accidentally overwritten at runtime.
A typical problem might be when the call isdigit('1') returns 0 rather than 1.
Most cases of such behaviour are caused by bypassing the C library standard initialization code, e.g., by providing your own __main() function. The best solution to this is to ensure that the C library's initialization code in __rt_lib_init() is called correctly. This will setup locale, and any other C library functions which need to be initialized, automatically.
Alternatively you may be able to work around the problem by using:
#include <locale.h>
setlocale(LC_ALL,"C");
However this is not recommend, especially as this will pull in additional parts of locale which may not be needed in your system (potentially around 1.4KB extra). It also leaves the possibility of other parts of the C library remaining uninitialized which may lead to later problems.