localeconv function(Get Locale Conventions) in C Language – example and detail

In the C Programming Language, the localeconv function returns a pointer to a shape that incorporates modern-day locale information.

Syntax

The syntax for the localeconv characteristic in the C Language is:

struct lconv *localeconv(void);

Returns

The localeconv feature returns a pointer to a structure that contains modern-day locale information.

Required Header

In the C Language, the required header for the localeconv characteristic is:

#include <locale.h>

Applies To

In the C Language, the localeconv feature can be used in the following versions:

ANSI/ISO 9899-1990

localeconv Example

/* Example using localeconv by TechOnTheNet.com */

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

int main(int argc, const char * argv[])
{
    /* Define a temporary variable */
    struct lconv *loc;

    /* Set the locale to the environment default */
    setlocale (LC_ALL, "");

    /* Retrieve a pointer to the current locale */
    loc = localeconv();

    /* Display some of the locale settings */
    printf("Thousands Separator: %s\n", loc->thousands_sep);
    printf("Currency Symbol: %s\n", loc->currency_symbol);

    return 0;
}

When compiled and run on a computer in North America, this software will output:

Thousands Separator: ,
Currency Symbol: $

Other C features that are comparable to the localeconv function:

setlocale function <locale.h>