6_11:strftime 打印系统时间
来源:互联网 发布:mac能装搜狗输入法吗 编辑:程序博客网 时间:2024/05/16 06:14
一.源代码:
<bldc:/home/tingbinz/apue.3e/SBSCODE/6>R*_*G:cat -n 6_11.c
1 #include <stdio.h>2 #include <stdlib.h>
3 #include <time.h>
4
5 int main()
6 {
7 time_t t;
8 struct tm *tmp;
9 char buf1[16];
10 char buf2[64];
11
12 time(&t);
13 tmp = localtime(&t);
14
15 if (strftime(buf1,16,"time and date: %r, %a %b %d, %Y", tmp) == 0)
16 printf("buffer length 16 is too small\n");
17 else
18 printf("%s\n",buf1);
19 if (strftime(buf2,64,"time and date: %r, %a %b %d, %Y", tmp) == 0)
20 printf("buffer length 64 is too small\n");
21 else
22 printf("%s\n",buf2);
23
24 exit(0);
25 }
二、运行结果:
<bldc:/home/tingbinz/apue.3e/SBSCODE/6>R*_*G:./what_is_the_time
buffer length 16 is too small
time and date: 12:03:11 AM, Wed Sep 30, 2015
0 0
- 6_11:strftime 打印系统时间
- 获取系统时间格式strftime
- C语言 获取系统时间方法(strftime())
- strftime操作时间详解
- strftime时间格式参考
- strftime 时间格式化
- 时间格式化函数strftime
- 时间格式化函数--strftime
- strftime,strptime系统函数
- python 打印系统时间
- 打印当前系统时间
- 打印系统当前时间
- 教务管理系统8_11
- strftime() 函数---> 时间格式化
- strftime() 函数将时间格式化
- strftime函数将时间格式化
- strftime函数将时间格式化
- php——strftime函数取得系统时间,同时熟悉switch用法
- Android-Universal-Image-Loader 图片加载库
- 2015上半年学习总结
- Mac下抓取iPhone数据包的方法——无需越狱
- 项目四——建设双链表算法库
- UIImageView添加边框和阴影
- 6_11:strftime 打印系统时间
- C语言中的贪心法
- Matlab中显示法线方向 display normal map in matlab
- Oracle多行函数/组函数
- 函数返回局部变量
- 使用FlowDroid生成Android应用程序的函数调用图
- Linux-循环控制/for
- 截屏并保存
- 毕设帮(5188.help)开发日志3——最小原型、迭代式开发