C localeconv() Function

Beginner
6 min read
Updated: Nov 2026
3 examples
locale.h

Definition

In C, localeconv() returns a pointer to a struct lconv that describes how numbers and money are written in the current locale. It is declared in <locale.h>.

Common fields include decimal_point, thousands_sep, and currency_symbol. Call it after setlocale() if you want the user locale, not the default C locale.

Syntax

Call localeconv with no arguments. It reads the current locale.

C
localeconv();
CallWhat it does
localeconv();Returns a pointer to formatting fields for the active locale.

Include <locale.h>. Pair with setlocale() when you need a non-default locale.

Library declarations
C
struct lconv *localeconv(void);

Parameters

ParameterDescription
(none)localeconv() takes no parameters. It uses the program’s current locale.

Return Value

Return ValueDescription
struct lconv *Pointer to a static object with locale formatting fields. Do not free it.

C Examples

Example 1 — Read the Decimal Point Character

Print the decimal point string for the current locale (often "." in the C locale).

C
#include <stdio.h>
#include <locale.h>

int main(void) {
    struct lconv *lc = localeconv();
    printf("decimal_point = \"%s\"\n", lc->decimal_point);
    return 0;
}

How It Works

  1. Include locale.h. That declares localeconv and struct lconv.
  2. Call localeconv(). It returns a pointer to the current formatting record.
  3. Read decimal_point. In the default C locale this is usually a single dot.
  4. Print safely. Treat the field as a C string and quote it in the output.

Example 2 — Read Fields After setlocale()

Switch to the C locale explicitly, then read decimal_point and thousands_sep.

C
#include <stdio.h>
#include <locale.h>

int main(void) {
    if (setlocale(LC_ALL, "C") == NULL) {
        printf("setlocale failed\n");
        return 1;
    }

    struct lconv *lc = localeconv();
    printf("decimal_point = \"%s\"\n", lc->decimal_point);
    printf("thousands_sep = \"%s\"\n", lc->thousands_sep);
    return 0;
}

How It Works

  1. Set a known locale. setlocale(LC_ALL, "C") selects the portable C locale.
  2. Check for NULL. A failed change leaves the previous locale in place.
  3. Call localeconv(). Now the lconv fields match the C locale.
  4. Inspect separators. The C locale typically uses . and an empty thousands separator.

Example 3 — Look at Currency-Related Fields

Print a few monetary fields. Exact strings vary by system locale support.

C
#include <stdio.h>
#include <locale.h>

int main(void) {
    setlocale(LC_ALL, "C");
    struct lconv *lc = localeconv();

    printf("currency_symbol = \"%s\"\n", lc->currency_symbol);
    printf("positive_sign   = \"%s\"\n", lc->positive_sign);
    printf("negative_sign   = \"%s\"\n", lc->negative_sign);
    return 0;
}

How It Works

  1. Stay in C locale. Monetary fields are often empty in the portable C locale.
  2. Read currency_symbol. User locales may fill this with a currency mark.
  3. Read sign fields. positive_sign and negative_sign describe how signs are written.
  4. Expect variation. On another machine or locale name, these strings can differ.

Frequently Asked Questions

It returns a pointer to struct lconv with formatting details such as decimal_point for the current locale.
Include <locale.h> before calling localeconv().
No. It points to static storage managed by the library.
The C locale leaves many monetary fields empty. User locales may fill them, depending on the system.
After setlocale() if you need non-default formatting. Programs start in the C locale.

Next: setlocale() Function

Learn how to change or query the program locale first.

setlocale() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful