Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
1st Parameter
Specifies the category of locale information to be modified or queried, such as `LC_ALL`, `LC_TIME`, or `LC_NUMERIC`.
2nd Parameter Type : const char *
Pointer to read-only string
2nd Parameter
A pointer to a string specifying the locale to set. If `locale` is `NULL`, the current setting for the specified category is returned.
Read more about parameters of setlocale in parameters section
The setlocalefunction in C language Sets or queries the program's locale.
The setlocale function is used to set or query the program's current locale. The locale affects the behavior of functions that are sensitive to cultural differences, such as the formatting of numbers, dates, and currency values. It can set the entire locale or specific categories of the locale.
The setlocalefunction takes 2
parameters:
•
int `category`: Specifies the category of locale information to be modified or queried, such as `LC_ALL`, `LC_TIME`, or `LC_NUMERIC`.
•
const char * `locale`: A pointer to a string specifying the locale to set. If `locale` is `NULL`, the current setting for the specified category is returned.
Sets or retrieves the current locale for a specified category. If `locale` is not `NULL`, the function sets the locale for `category` to the specified value. If `locale` is `NULL`, the function returns the name of the current locale for the category. Returns a pointer to the name of the locale set, or `NULL` if the locale cannot be set.
The setlocale function return value :
Returns a pointer to a string identifying the new locale on success, or NULL on failure
If the second argument is NULL, it returns the current locale string without changing it
Output
This example sets the program's locale to the system default and then prints a locale-dependent floating-point number.