C Tutorial/time.h/setlocale

Материал из C\C++ эксперт
Перейти к: навигация, поиск

setlocale

Item Value Header file locale.h Declaration char *setlocale(int type, const char *locale); Function set local information

type must be one of the following macros (defined in <locale.h>):

  1. LC_ALL: refers to all localization categories.
  2. LC_COLLATE: affects the operation of the strcoll() function.
  3. LC_CTYPE: alters the way the character functions work.
  4. LC_MONETARY: determines the monetary format.
  5. LC_NUMERIC: changes the decimal-point character for formatted input/output functions.
  6. LC_TIME: determines the behavior of the strftime() function.

The setlocale() function returns a pointer to a string associated with the type parameter.

Display the current locale setting:


<source lang="cpp">#include <locale.h>

 #include <stdio.h>
 int main(void)
 {
   printf(setlocale(LC_ALL, ""));
   return 0;
 }</source>