Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
#include <locale.h>
struct lconv *localeconv(void);
Sets the components of a structure having type struct lconv to values appropriate for the current locale. The structure may be overwritten by another call to localeconv() or by calling setlocale() and passing LC_ALL, LC_MONETARY, or LC_NUMERIC.
For a list of the elements in the lconv structure, see Table 1.
Pointers to strings with a value of "" indicate that the value is not available in the C locale or is of 0 length. char types with a value of UCHAR_MAX indicate that the value is not available in the current locale.
Returns a pointer to the structure.
⁄* CELEBL06
This example prints out the default decimal point for your locale and
then the decimal point for the Fr_CA locale.
*⁄
#include <stdio.h>
#include <locale.h>
int main(void)
{
char * string;
struct lconv * mylocale;
mylocale = localeconv();
⁄* Display default decimal point *⁄
printf( "Default decimal point is a %s\n",
mylocale->decimal_point );
if (NULL != (string = setlocale(LC_ALL, "Fr_CA.IBM-1047" )))
{
mylocale = localeconv();
⁄* A comma is set to be the decimal point
when the locale is Fr_CA.IBM-1047 *⁄
printf( "French-speaking Canadian decimal point is a %s\n",
mylocale->decimal_point );
}
else {
printf("setlocale(LC_ALL, Fr_CA.IBM-1047) returned <NULL>\n");
}
return 0;
}
Default decimal-point is a .
French-speaking Canadian decimal-point is a ,