totn C Functions

C Language: localeconv function
(Get Locale Conventions)

In the C Programming Language, the localeconv function returns a pointer to a structure that contains current locale information.

Syntax

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

struct lconv *localeconv(void);

Returns

The localeconv function returns a pointer to a structure that contains current locale information.

Required Header

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

#include <locale.h>

Applies To

In the C Language, the localeconv function 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 machine in North America, this application will output:

Thousands Separator: ,
Currency Symbol: $

Other C functions that are similar to the localeconv function: