Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* setlocale example */
#include <stdio.h> /* printf */
#include <time.h> /* time_t, struct tm, time, localtime, strftime */
#include <locale.h> /* struct lconv, setlocale, localeconv */ int main ()
{
time_t rawtime;
struct tm * timeinfo;
char buffer [80]; struct lconv * lc; time ( &rawtime );
timeinfo = localtime ( &rawtime ); int twice=0; do {
printf ("Locale is: %s\n", setlocale(LC_ALL,NULL) ); strftime (buffer,80,"%c",timeinfo);
printf ("Date is: %s\n",buffer); lc = localeconv ();
printf ("Currency symbol is: %s\n-\n",lc->currency_symbol); setlocale (LC_ALL,"");
} while (!twice++); return 0;
}

One of the possible outputs when the previous code is run is:

Locale is: C
Date is: 01/15/07 13:33:47
Currency symbol is:
-
Locale is: English_United States.1252
Date is: 1/15/07 1:33:47 PM
Currency symbol is: $
-

http://www.cplusplus.com/reference/clocale/setlocale/

C语言的setlocale和localtime函数(C++也可用)的更多相关文章

  1. C语言样式的文件操作函数

    使用C语言样式的文件操作函数,需要包含stdio.h头文件. 1.打开文件的函数: //oflag的取值为“w”或“r”,分别表示以写或读的方式打开 FILE* fd = fopen(filename ...

  2. C语言带参数的main函数

    C语言带参数的main函数 #include<stdio.h> int main(int argc,char*argv[]) { int i; ;i<argc;i++) printf ...

  3. C 语言的可变参数表函数的设计

    在c语言中使用变长参数最常见的就是下面两个函数了: int printf(const char *format, ...); int scanf(const char *format, ...); 那 ...

  4. 智能合约语言 Solidity 教程系列3 - 函数类型

    Solidity 教程系列第三篇 - Solidity 函数类型介绍. 写在前面 Solidity 是以太坊智能合约编程语言,阅读本文前,你应该对以太坊.智能合约有所了解,如果你还不了解,建议你先看以 ...

  5. C语言中可变参数的函数(三个点,“...”)

    C语言中可变参数的函数(三个点,“...”) 本文主要介绍va_start和va_end的使用及原理. 在以前的一篇帖子Format MessageBox 详解中曾使用到va_start和va_end ...

  6. localtime函数和strftime函数

    localtime函数 功能: 把从1970-1-1零点零分到当前时间系统所偏移的秒数时间转换为本地时间,而gmtime函数转换后的时间没有经过时区变换,是UTC时间 . 用法: #include & ...

  7. Linux C 中获取local日期和时间 time()&localtime()函数

    1.  time() 函数 /* time - 获取计算机系统当前的日历时间(Calender Time) * 处理日期时间的函数都是以本函数的返回值为基础进行运算 * * 函数原型: * #incl ...

  8. Go语言学习笔记七: 函数

    Go语言学习笔记七: 函数 Go语言有函数还有方法,神奇不.这有点像python了. 函数定义 func function_name( [parameter list] ) [return_types ...

  9. C语言对文件的操作函数用法详解2

    fopen(打开文件) 相关函数 open,fclose 表头文件 #include<stdio.h> 定义函数 FILE * fopen(const char * path,const  ...

随机推荐

  1. erlang中如何调试程序

    学习一门语言,当学习那些基本语法的时候,我们常常会忽略它的程序调试,当程序稍微复杂一点的时候,我们不能保证程序的完全正确,我们会为其发愁,这时,程序的调试就变得相当重要了.    在erlang环境搭 ...

  2. 过滤Filter推断用户是否登录

    WEB.XML <!-- 用户session的 键 sessionKEY --> <context-param> <param-name>userSessionKe ...

  3. 关于Dagger 2的文章汇总

    首先是我真正看懂了的第一篇文章 代码GG之家的 Dagger2图文详解 这篇文章很直接,还配有代码demo.至少我是看懂了. Dagger2 使用详解 这篇文章同样配有demo,同时文末还有很多有用的 ...

  4. 【23.24%】【codeforces 629C】Famil Door and Brackets

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 构建工具Gradle

    1.Summary   从Android团队开始宣布放弃Eclipse转投Android Studio时,构建工具Gradle进入了Android开发者的视野.而随着热修复.插件化.编译时注解的流行, ...

  6. Mobile Push Notification

    In one embodiment, a method includes sending to a mobile client computing device a first notificatio ...

  7. 我是如何进行code review的

    众所周知,代码审查是软件开发过程中十分重要的环节,楼主结合自己的实际工作经验,和大家分享一下在实际工作中代码审查是如何开展的, 笔者水平有限,若有错误和纰漏,还请大家指正. 代码审查的阻力 我想不通公 ...

  8. LockWindowUpdate的函数的用法

    Application.ProcessMessages;LockWindowUpdate(Self.Handle); //锁住当前窗口 LockWindowUpdate(0)//解除锁定窗口 Lock ...

  9. Theano 编程核心

    1. 求偏导.更新以及模型的训练 以 LogisticRegression 为例: 求损失函数关于参数的偏导: import theano.tensor as T g_W = T.gradient(c ...

  10. OpenGL(二十) glutSpecialFunc响应键盘方向控制键

    OpenGL的glut中使用glutMouseFunc函数注册鼠标响应事件,使用glutKeyboardFunc函数注册键盘响应事件,对键盘上特殊的4个方向按键的响应函数是glutSpecialFun ...