C 库函数 - localeconv()
C 语言教程
· 2019-02-22 23:42:36
描述
C 库函数 struct lconv *localeconv(void) 设置或读取地域化信息。它会返回一个 lconv 结构类型的对象。
声明
下面是 localeconv() 函数的声明。
struct lconv *localeconv(void)
参数
- NA
返回值
该函数返回一个指向当前区域 struct 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 语言教程 文章: https://codercto.com/courses/l/17.html
正则表达式必知必会
Ben Forta / 杨涛、王建桥、杨晓云 / 人民邮电出版社 / 2007 / 29.00元
正则表达式是一种威力无比强大的武器,几乎在所有的程序设计语言里和计算机平台上都可以用它来完成各种复杂的文本处理工作。本书从简单的文本匹配开始,循序渐进地介绍了很多复杂内容,其中包括回溯引用、条件性求值和前后查找,等等。每章都为读者准备了许多简明又实用的示例,有助于全面、系统、快速掌握正则表达式,并运用它们去解决实际问题。 本书适合各种语言和平台的开发人员。一起来看看 《正则表达式必知必会》 这本书的介绍吧!