##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# setlocale

From cppreference.com
< c‎ | locale

Defined in header `<locale.h>` |  |
char* setlocale( int category, const char* locale); |  |

The `setlocale` function installs the specified system locale or its portion as the new C locale. The modifications remain in effect and influences the execution of all locale-sensitive C library functions until the next call to `setlocale`. If `locale` is a null pointer, `setlocale` queries the current C locale without modifying it.

### [edit] Parameters

category | - | locale category identifier, one of the LC_xxx macros. May be null.
locale | - | system-specific locale identifier. Can be "" for the user-preferred locale or "C" for the minimal locale

### [edit] Return value

pointer to a narrow null-terminated string identifying the C locale after applying the changes, if any, or null pointer on failure.

### [edit] Notes

During program startup, the equivalent of setlocale(LC_ALL, "C"); is executed before any user code is run.

Although the return type is char*, modifying the pointed-to characters is undefined behavior.

Because `setlocale` modifies global state which affects execution of locale-dependent functions, it is undefined behavior to call it from one thread, while another thread is executing any of the following functions: fprintf, isprint, iswdigit, localeconv, tolower, fscanf, ispunct, iswgraph, mblen, toupper, isalnum, isspace, iswlower, mbstowcs, towlower, isalpha, isupper, iswprint, mbtowc, towupper, isblank, iswalnum, iswpunct, setlocale, wcscoll, iscntrl, iswalpha, iswspace, strcoll, wcstod, isdigit, iswblank, iswupper, strerror, wcstombs, isgraph, iswcntrl, iswxdigit, strtod, wcsxfrm, islower, iswctype, isxdigit.

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME | locale categories for setlocale (macro constant) [edit]
C++ documentation for setlocale

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/locale/setlocale&oldid=56503"
Category:

- Todo no example