Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

localeconv — C23 locale function

`localeconv()` from `<locale.h>` returns a pointer to a `struct lconv` describing current numeric and monetary formatting, including `decimal_point`, grouping separators, and currency signs. It does not change the locale.

Version: C23

Syntax

struct lconv *localeconv(void);

localeconv() from <locale.h> returns a pointer to a struct lconv describing current numeric and monetary formatting, including decimal_point, grouping separators, and currency signs. It does not change the locale.

The example runs in the initial C locale, calls localeconv(), and prints . 0: the decimal point and the length of the empty thousands separator. It is a real read of structure members.

The pointer designates library-managed storage; the program must not modify the object, and a later localeconv() or setlocale() may overwrite its data. Copy needed strings before changing locale. An empty string or CHAR_MAX in a character-valued member denotes unavailable information according to that member’s contract; the global locale is shared state and requires synchronization.

Examples

#include <locale.h>
#include <stdio.h>
#include <string.h>
int main(void){struct lconv *v=localeconv();printf("%s %zu\n",v->decimal_point,strlen(v->thousands_sep));return 0;}

Result

. 0

The example runs in the initial `C` locale, calls `localeconv()`, and prints `. 0`: the decimal point and the length of the empty thousands separator. It is a real read of structure members.

Sources