6.10.5 setlocale Function
Selects the appropriate portion of the program’s locale.
"C"
locale is supported.Include
<locale.h>
Prototype
char * setlocale(int category, const char * locale);
Arguments
category
- the portion of the locale to change, specified by macros
LC_ALL
,LC_NUMERIC
etc. locale
- a string representing the environment to set
Return Value
The function returns a pointer to the string associated with the specified category for the
new locale. If the selection cannot be honored, the function returns a null pointer and the
program’s locale is not changed. If locale
is a null pointer, the function
returns a pointer to the string associated with the category for the program’s current
locale.
Remarks
The function sets the environment, specified by the locale
argument, in the
portion of the program’s locale, as specified by the category
argument. If
locale
is a null pointer, the locale is not set.
Those MPLAB XC compilers that implement setlocale()
only support the
"C"
for locale
, which specifies the minimal environment
for C translation.
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <locale.h>
struct lconv * ll;
int main(void) {
ll = localeconv();
setlocale(LC_ALL, "C");
}