Facebook Page Twitter Page LinkedIn Page
× C Standard Library

The C <locale.h> contains LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME macro constants. Each of these macro constants expand to integer constant expressions with distinct values that are suitable for use with setlocale() function as the first argument.

LC_ALL Selects the entire C locale.
LC_COLLATE Selects the collation category of the C locale.
LC_CTYPE Selects the character classification category of the C locale.
LC_MONETARY Selects the monetary formatting category of the C locale.
LC_NUMERIC Selects the numeric formatting category of the C locale.
LC_TIME Selects the time formatting category of the C locale.

Definition in the <locale.h> header file is:

#define LC_ALL      /*implementation defined*/
#define LC_COLLATE  /*implementation defined*/
#define LC_CTYPE    /*implementation defined*/
#define LC_MONETARY /*implementation defined*/
#define LC_NUMERIC  /*implementation defined*/
#define LC_TIME     /*implementation defined*/


The below example shows the usage of these macros.

#include <stdio.h>
#include <time.h>
#include <locale.h>
int main (){
  time_t t = time(NULL);
  char buffer [80];

  printf("Local is: %s\n", setlocale(LC_ALL,"en_US.UTF-8"));

  //monetary formatting will be British
  setlocale(LC_MONETARY, "en_GB.utf8");  
  struct lconv *lc = localeconv();

  printf("Local Currency Symbol: %s\n", 

  //time formatting will be British
  setlocale(LC_TIME, "en_GB.utf8"); 
  strftime (buffer,80,"%c",localtime(&t));
  printf("Date is: %s\n", buffer);

  return 0;

The output of the above code will be:

Local is: en_US.UTF-8
Local Currency Symbol: £
Date is: Sat 01 May 2021 05:01:45 UTC

❮ C <locale.h> Library