Syntax
#include <locale.h> struct lconv *localeconv(void);Description
localeconv retrieves information about the environment for the current locale and places the information in a structure of type struct lconv. Subsequent calls to localeconv, or to setlocale with the argument LC_ALL, LC_MONETARY, or LC_NUMERIC, can overwrite the structure.
The structure contains the members listed below. Pointers to strings with
a value of "" indicate that the value is not available in this locale or
is of zero length. Character types with a value of CHAR_MAX indicate that
the value is not available in this locale. ┌──────────────────────┬──────────────────────────────────────────┐
│ Element        │ Purpose of Element            │
├──────────────────────┼──────────────────────────────────────────┤
│ "char         │ Decimal-point character for formatting  │
│ *decimal_point"    │ nonmonetary quantities.          │
├──────────────────────┼──────────────────────────────────────────┤
│ "char         │ Character used to separate groups of   │
│ *thousands_sep"    │ digits to the left of the decimal-point  │
│            │ character in formatted nonmonetary quan- │
│            │ tities.                  │
├──────────────────────┼──────────────────────────────────────────┤
│ "char *grouping"   │ Size of each group of digits in for-   │
│            │ matted nonmonetary quantities.  The    │
│            │ value of each character in the string   │
│            │ determines the number of digits in a   │
│            │ group.  "CHAR_MAX" indicates that there  │
│            │ are no further groupings.  If the last  │
│            │ integer is not "CHAR_MAX", then the size │
│            │ of the previous group will be used for  │
│            │ the remainder of the digits.       │
├──────────────────────┼──────────────────────────────────────────┤
│ "char         │ International currency symbol.  The    │
│ *int_curr_symbol"   │ first three characters contain the    │
│            │ alphabetic international currency     │
│            │ symbol.  The fourth character (usually a │
│            │ space) separates the international cur-  │
│            │ rency symbol from the monetary quantity. │
├──────────────────────┼──────────────────────────────────────────┤
│ "char         │ Local currency symbol.          │
│ *currency_symbol"   │                      │
├──────────────────────┼──────────────────────────────────────────┤
│ "char         │ Decimal-point character for formatting  │
│ *mon_decimal_point"  │ monetary quantities.           │
├──────────────────────┼──────────────────────────────────────────┤
│ "char         │ Separator for digits in formatted mone-  │
│ *mon_thousands_sep"  │ tary quantities.             │
├──────────────────────┼──────────────────────────────────────────┤
│ "char *mon_grouping" │ Size of each group of digits in for-   │
│            │ matted monetary quantities.  The value  │
│            │ of each character in the string deter-  │
│            │ mines the number of digits in a group.  │
│            │ "CHAR_MAX" indicates that there are no  │
│            │ further groupings.  If the last integer  │
│            │ is not "CHAR_MAX", then the size of the  │
│            │ previous group will be used for the    │
│            │ remainder of the digits.         │
├──────────────────────┼──────────────────────────────────────────┤
│ "char         │ Positive sign used in monetary quanti-  │
│ *positive_sign"    │ ties.                   │
├──────────────────────┼──────────────────────────────────────────┤
│ "char         │ Negative sign used in monetary quanti-  │
│ *negative_sign"    │ ties.                   │
├──────────────────────┼──────────────────────────────────────────┤
│ "char         │ Mumber of displayed digits to the right  │
│ int_frac_digits"   │ of the decimal place for internationally │
│            │ formatted monetary quantities.      │
├──────────────────────┼──────────────────────────────────────────┤
│ "char frac_digits"  │ Number of digits to the right of the   │
│            │ decimal place in monetary quantities.   │
├──────────────────────┼──────────────────────────────────────────┤
│ "char p_cs_precedes" │ 1 if the "currency_symbol" precedes the  │
│            │ value for a nonnegative formatted mone-  │
│            │ tary quantity; "0" if it does not.    │
├──────────────────────┼──────────────────────────────────────────┤
│ "char         │ 1 if the "currency_symbol" is separated  │
│ p_sep_by_space"    │ by a space from the value of a nonnega-  │
│            │ tive formatted monetary quantity;  "0"  │
│            │ if it is not.               │
├──────────────────────┼──────────────────────────────────────────┤
│ "char n_cs_precedes" │ 1 if the "currency_symbol" precedes the  │
│            │ value for a negative formatted monetary  │
│            │ quantity; "0" if it does not.       │
├──────────────────────┼──────────────────────────────────────────┤
│ "char         │ 1 if the "currency_symbol" is separated  │
│ n_sep_by_space"    │ by a space from the value of a negative  │
│            │ formatted monetary quantity;  "0" if it  │
│            │ is not.                  │
├──────────────────────┼──────────────────────────────────────────┤
│ "char p_sign_posn"  │ Position of the "positive_sign" for a   │
│            │ nonnegative formatted monetary quantity. │
├──────────────────────┼──────────────────────────────────────────┤
│ "char n_sign_posn"  │ Position of the "negative_sign" for a   │
│            │ negative formatted monetary quantity.   │
└──────────────────────┴──────────────────────────────────────────┘
┌──────────────────────┬──────────────────────────────────────────┐
│ "char         │ Symbol to appear to the left of a     │
│ *left_parenthesis"  │ negative-valued monetary symbol (such as │
│            │ a loss or deficit).            │
├──────────────────────┼──────────────────────────────────────────┤
│ "char         │ Symbol to appear to the right of a    │
│ *right_parenthesis"  │ negative-valued monetary symbol (such as │
│            │ a loss or deficit).            │
├──────────────────────┼──────────────────────────────────────────┤
│ "char *debit_sign"  │ String to indicate a non-negative-valued │
│            │ formatted monetary quantity.       │
├──────────────────────┼──────────────────────────────────────────┤
│ "char *credit_sign"  │ String to indicate a negative-valued   │
│            │ formatted monetary quantity.       │
└──────────────────────┴──────────────────────────────────────────┘
The grouping and mon_grouping members can have the following values:
Value
The n_sign_posn and p_sign_posn elements can have the following values:
Value
This example prints out the default decimal point for your locale and then the decimal point for the Fr_FR.IBM-850 locale.
#include <stdio.h>#include <locale.h>
int main(void)
{
   struct lconv *mylocale;
   mylocale = localeconv();
   printf("Default decimal point is a %s\n", mylocale->decimal_point);
   if (NULL != setlocale(LC_ALL, Fr_FR.IBM-850)) {
      mylocale = localeconv();
      printf("France's decimal point is a %s\n", mylocale->decimal_point);
   } else {
      printf("setlocale(LC_ALL, Fr_FR.IBM-850) returned <NULL>\n");
    }
   return 0;
   /****************************************************************************
      The output should be similar to :
      Default decimal point is a .
      France's decimal point is a ,
   ****************************************************************************/
}
Related Information