Latest web development tutorials

Cライブラリ関数 - のlocaleconv()

C標準ライブラリ -  <locale.hに> C標準ライブラリ- <locale.hに>

説明

Cライブラリ関数の構造体lconv *のlocaleconv(ボイド)が設定またはローカルな情報をお読みください。 これは、型lconv構造体のオブジェクトを返します。

声明

ここで、()文のlocaleconv関数です。

struct lconv *localeconv(void)

パラメータ

  • NA

戻り値

この関数は次のようにそれが構成され、ポインタの構造体lconv現在の領域へのポインタを返します。

typedef struct {
   char *decimal_point;
   char *thousands_sep;
   char *grouping;	
   char *int_curr_symbol;
   char *currency_symbol;
   char *mon_decimal_point;
   char *mon_thousands_sep;
   char *mon_grouping;
   char *positive_sign;
   char *negative_sign;
   char int_frac_digits;
   char frac_digits;
   char p_cs_precedes;
   char p_sep_by_space;
   char n_cs_precedes;
   char n_sep_by_space;
   char p_sign_posn;
   char n_sign_posn;
} lconv

次の例は、のlocaleconv()関数が使用されている示しています。

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

int main ()
{
   struct lconv * lc;

   setlocale(LC_MONETARY, "it_IT");
   lc = localeconv();
   printf("Local Currency Symbol: %s\n",lc->currency_symbol);
   printf("International Currency Symbol: %s\n",lc->int_curr_symbol);

   setlocale(LC_MONETARY, "en_US");
   lc = localeconv();
   printf("Local Currency Symbol: %s\n",lc->currency_symbol);
   printf("International Currency Symbol: %s\n",lc->int_curr_symbol);

   setlocale(LC_MONETARY, "en_GB");
   lc = localeconv();
   printf ("Local Currency Symbol: %s\n",lc->currency_symbol);
   printf ("International Currency Symbol: %s\n",lc->int_curr_symbol);

   printf("Decimal Point = %s\n", lc->decimal_point);
   
   return 0;
}

それでは、以下になります上記のプログラムを、コンパイルして実行してみましょう:

Local Currency Symbol: EUR
International Currency Symbol: EUR
Local Currency Symbol: $
International Currency Symbol: USD
Local Currency Symbol: £
International Currency Symbol: GBP
Decimal Point = .

C標準ライブラリ -  <locale.hに> C標準ライブラリ- <locale.hに>