Full prototype:

char* setlocale(int, const char*);  

Purpose and Notes:

First thing to note: Locale for computers controls how your computer interprets 1s and 0s given for the geographical area. This affects how it interprets different character sets, to how it formats the date and time, to what formatting conventions for numbers and money.

This function sets the locale "category" (first argument) to the value of the second argument. Available "categories" are: LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, and LC_TIME. When those categories are set to a specific locale functions like those in the ctype.h header will behave according to the newly set locale. Other functions like strftime and wcsftime will also behaive differently based on the locale that is set.


char*- A null terminated string corresponding to the newly set locale for the "category", or NULL if there was a failure setting the locale.

Argument 1:

int- A "category" identifier including one of the LC_XXX mentioned above. This argument is used to limit the scope of the locale you are trying to set, so you can effect just some functions and functionality and not others or you can change them all if you desire.

Argument 2:

const char*- This is the actual setting you want to change the "category" too. When this is set, it will change the behavior of the "category" of functions.

Example 1