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. Centos 6.x 配置hadoop的环境变量

    1.安装jdk 原来是用的rpm安装的1.7,所以先使用rpm -qa|grep jdk,找到安装的1.7后 rpm -e --nodeps xxx.使用securecrt把官网下载的jdk-8u18 ...

  2. js 图片缩显

    <script language="javascript"> var flag=false;  function MyImage(Img){  var image=ne ...

  3. 设计模式在JDK中的应用

    在JDK(Java Development Kit)类库中,开发人员使用了大量设计模式. 创建型模式: (1) 抽象工厂模式(Abstract Factory) • java.util.Calenda ...

  4. OpenCL基本概念

    OpenCL程序同CUDA程序一样,也是分为两部分,一部分是在主机(以CPU为核心)上运行,一部分是在设备(以GPU为核心)上运行.在设备上运行的程序被称为核函数.但是对于核函数的编写,CUDA一般直 ...

  5. 2 Task中的延续和7种阻塞

    1.wait using System; using System.Threading; using System.Threading.Tasks; namespace 多线程_List { clas ...

  6. C#常用多线程方法

    1.  Thread类 C#多线程编程中Thread类需要包含名称空间System.Threading. class Program { static void Main(string[] args) ...

  7. B 维背包+完全背包 Hdu2159

    <span style="color:#3333ff;">/* ---------------------------------------------------- ...

  8. WinEdt && LaTex(三)—— 宏包

    amsmath:最常用的数学宏包 1. bm:bold math 数学字体加粗 \documentclass{article} \usepackage{bm} \begin{document} \[ ...

  9. ASP.NET Core 静态文件 - ASP.NET Core 基础教程 - 简单教程,简单编程

    原文:ASP.NET Core 静态文件 - ASP.NET Core 基础教程 - 简单教程,简单编程 ASP.NET Core 静态文件 前几章节中,我们学习了 ASP.NET Core 的中间件 ...

  10. WPF 走马灯 文字滚动 自定义控件

    原文:WPF 走马灯 文字滚动 自定义控件 /// <summary> /// Label走马灯自定义控件 /// </summary> [ToolboxBitmap(type ...