😸
[C] localeconv 関数
機能
localeconv
関数は、ロケール(地域と言語の設定)に依存する数値や通貨の書式情報を取得するための関数。[1]
使用例
小数点記号: .
と表示する
\n
は改行を表す エスケープシーケンス[2]
コード
#include <locale.h>
#include <stdio.h>
int main() {
struct lconv *lc = localeconv();
printf("小数点記号: %s\n", lc->decimal_point);
return 0;
}
全文
#include <locale.h>
#include <stdio.h>
int main() {
struct lconv *lc = localeconv();
printf("小数点記号: %s\n", lc->decimal_point);
return 0;
}
実行結果
小数点記号: .
小数点記号: ,
をロケールを設定して表示する
コード
#include <locale.h>
#include <stdio.h>
int main() {
setlocale(LC_ALL, "fr_FR.UTF-8");
struct lconv *lc = localeconv();
printf("小数点記号: %s\n", lc->decimal_point);
return 0;
}
全文
#include <locale.h>
#include <stdio.h>
int main() {
setlocale(LC_ALL, "fr_FR.UTF-8");
struct lconv *lc = localeconv();
printf("小数点記号: %s\n", lc->decimal_point);
return 0;
}
実行結果
小数点記号: ,
Discussion