c语言中time相关函数
工作中遇到的函数:
int seed = time(NULL);
srand(seed);
signal(SIGINT, stop);
signal(SIGUSR1, sig_usr1); 搜time函数时,看到相关time 函数的文章,粘贴如下:
-------------------------
from:http://blog.csdn.net/wangluojisuan/article/details/7045592
c语言中time函数的用法
版权声明:本文为博主原创文章,未经博主允许不得转载。
- struct tm{
- int tm_sec;
- int tm_min;
- int tm_hour;
- int tm_mday;
- int tm_mon;
- int tm_year;
- int tm_wday;
- int tm_yday;
- int tm_isdst;
- };
- #include <time.h>
- #include <stdio.h>
- #include <dos.h>
- int main() {
- time_t timer;
- struct tm *tblock;
- timer=time(NULL);
- tblock=localtime(&timer);
- printf("Local time is: %s",asctime(tblock));
- return 0;
- }
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
- int main() {
- struct tm t;
- char str[80];
- t.tm_sec=1;
- t.tm_min=3;
- t.tm_hour=7;
- t.tm_mday=22;
- t.tm_mon=11;
- t.tm_year=56;
- t.tm_wday=4;
- t.tm_yday=0;
- t.tm_isdst=0;
- strcpy(str,asctime(&t));
- printf("%s",str);
- return 0;
- }
- #include <stdio.h>
- #include <time.h>
- int main() {
- time_t t;
- time(&t);
- printf("Today's date and time: %s",ctime(&t));
- return 0;
- }
- #include <time.h>
- #include <stdio.h>
- #include <dos.h>
- #include <conio.h>
- int main() {
- time_t first, second;
- clrscr();
- first=time(NULL);
- delay(2000);
- second=time(NULL);
- printf("The difference is: %f seconds",difftime(second,first));
- getch();
- return 0;
- }
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <dos.h>
- char *tzstr="TZ=PST8PDT";
- int main() {
- time_t t;
- struct tm *gmt, *area;
- putenv(tzstr);
- tzset();
- t=time(NULL);
- area=localtime(&t);
- printf("Local time is:%s", asctime(area));
- gmt=gmtime(&t);
- printf("GMT is:%s", asctime(gmt));
- return 0;
- }
- #include <time.h>
- #include <stdio.h>
- #include <dos.h>
- int main() {
- time_t t;
- t=time();
- printf("The number of seconds since January 1,1970 is %ld",t);
- return 0;
- }
- #include <time.h>
- #include <stdlib.h>
- #include <stdio.h>
- int main() {
- time_t td;
- putenv("TZ=PST8PDT");
- tzset();
- time(&td);
- printf("Current time=%s",asctime(localtime(&td)));
- return 0;
- }
转载于:https://www.cnblogs.com/the-tops/p/5900163.html
c语言中time相关函数相关推荐
- c语言中shmget相关函数,unix中共享内存(shmget的实现,非mmap)
共享内存是系统出于多个进程之间通讯的考虑,而预留的的一块内存区.在/proc/sys/kernel/目录下,记录着共享内存的一些限制,如一 个共享内存区的最大字节数shmmax,系统范围内最大共享内存 ...
- c语言中shmget相关函数,共享内存函数(shmget、shmat、shmdt、shmctl)及其范例 - guoping16的专栏 - 博客频道 - CSDN...
2014年4月2日共享内存函数(shmget.shmat.shmdt.shmctl)及其范例 - guoping16的专栏 - 博客频道 - http://doc.xuehai.net 登录 | 注册 ...
- c语言用string类型,c语言中的string
1. strlen(char const* s); 函数传入的是c风格字符串(即以'\0'结尾的字符数组),返回的长度为size_t(即unsigned int),其长度不包括'\0'. 2. str ...
- c语言中用两个n表示什么格式,C语言中‘\n'为什么能表示CRLF两个字节
为什么要说这个简单的问题? 众所周知,在Windows下文本文件的换行符是CRLF,占两个字节.在Unix下是LF,占一个字节.(还有奇葩的Mac是CR).但是C语言中直接printf一个 '\n', ...
- go语言中fmt包中Print、Printf、Println输出相关函数的区别
go语言中fmt包中Print.Printf.Println输出相关函数的区别 区别: Print系列函数将内容输出到系统的标准输出.其区别:Print函数式直接输出内容,Printf函数支持格式化输 ...
- c语言 recv_sin,C++_C语言中经socket接收数据的相关函数详解,recv()函数:
头文件:#incl - phpStudy...
C语言中经socket接收数据的相关函数详解 recv()函数:头文件: #include #include 定义函数: int recv(int s, void *buf, int len, uns ...
- c语言中open函数r,C语言中open函数
语法Open ( windowvar, windowtype {, parent } ) 参数windowvar:指定窗口变量名,Open()函数把打开窗口的引用放置到该变量中windowtype:s ...
- c语言malloc作用,c语言中malloc是什么?怎么用?
c语言中malloc是什么?怎么用? malloc() 函数用来动态地分配内存空间,其原型为:void* malloc (size_t size); 说明: [参数说明] size 为需要分配的内存空 ...
- c语言中open的原理,C语言中open函数
语法Open ( windowvar, windowtype {, parent } ) 参数windowvar:指定窗口变量名,Open()函数把打开窗口的引用放置到该变量中windowtype:s ...
最新文章
- layui学习资料汇总
- java 编写命令行工具_编写命令行工具
- Spring JDBC 框架一个最简单的Hello World级别的例子
- uniapp底部弹出框效果
- DiagnosticsTextBox:WinForms的日志窗口
- NoSQL数据库之国产开源产品:SequoiaDB 分析前言
- java aes文件加密_JAVA AES文件加解密
- 高等数学复习要点(期末考试同济版)
- mac如何查看ssd寿命_固态硬盘ssd写入量剩余读写次数怎么查
- 解决SQLServer2008安装失败最直白的解决方式
- linux还原防火墙设置,Linux防火墙设置教程
- 艺多不压身 -- 目录
- 燕山大学联通新卡绑定校园网
- 好男儿当生三国 好女子当养唐朝
- 怎么把PicPick设置成中文版?
- python,你也和小猪佩奇一样社会了!
- xgboost 论文
- C#中的ExecuteNonQuery();
- 热插拔机制之udev和mdev
- 福建闽北卫生学校计算机考试,福建闽北卫生学校