From the The Linux Programming Interface:
There are two different methods of setting the locale using setlocale(). The locale
argument may be a string specifying one of the locales defined on the system (i.e.,
the name of one of the subdirectories under /usr/lib/locale), such as de_DE or en_US.
Alternatively, locale may be specified as an empty string, meaning that locale settings should be taken from environment variables:
We must make this call in order for a program to be cognizant of the locale environment variables. If the call is omitted, these environment variables will have no effect on the program.
Looking at the man
7.4 How Programs Set the Locale
A C program inherits its locale environment variables when it starts up. This happens automatically. However, these variables do not automatically control the locale used by the library functions, because ISO C says that all programs start by default in the standard ‘C’ locale. To use the locales specified by the environment, you must call setlocale. Call it as follows:
setlocale (LC_ALL, "");