setlocale function sets locale(local information)

Syntax

C setlocale function has the following syntax.

char *setlocale(int type, const char *locale);

C setlocale function is from header file locale.h.

Description

C setlocale function sets local information.

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

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

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

Example

Use C setlocale function to set the current locale information.


#include <locale.h>
#include <stdio.h>
/*from w w  w. j a  v  a 2s.c o  m*/
int main(void)
{
  printf(setlocale(LC_ALL, ""));

  return 0;
}

The code above generates the following result.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h