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;
- }
c语言中time相关函数的更多相关文章
- C语言中的isalpha,isdigit,islower,isupper等一系列函数
TITLE:c语言中的isalpha,isdigit,islower,isupper等一系列函数 已经全部验证检查,无任何错误 isalnum(测试字符是否为英文或数字) 相关函数 isalpha,i ...
- C语言中,头文件和源文件的关系(转)
简单的说其实要理解C文件与头文件(即.h)有什么不同之处,首先需要弄明白编译器的工作过程,一般说来编译器会做以下几个过程: 1.预处理阶段 2.词法与语法分析阶段 3.编译阶段,首先编译成纯汇编语句, ...
- C 语言中 setjmp 和 longjmp
在 C 语言中,我们不能使用 goto 语句来跳转到另一个函数中的某个 label 处:但提供了两个函数——setjmp 和 longjmp来完成这种类型的分支跳转.后面我们会看到这两个函数在处理异常 ...
- c语言中的scanf在java中应该怎么表达,Scanner类。
1 java是面向对象的语言 它没有像C语言中的scanf()函数,但是它的类库中有含有scanf功能的函数 2 java.util包下有Scanner类 Scanner类的功能与scanf类似 3 ...
- C语言中do...while(0)的妙用(转载)
转载来自:C语言中do...while(0)的妙用,感谢分享. 在linux内核代码中,经常看到do...while(0)的宏,do...while(0)有很多作用,下面举出几个: 1.避免goto语 ...
- C语言中,定义的含义?声明的含义?它们之间的区别是什么?
在C语言中,对于定义和声明,也许我们非常的熟悉,但不一定真正的了解! 定义的含义:所谓定义,就是创建(编译器)一个对象,为这个对象分配一块内存空间并取名,也就是我们平常所说的变量名或对象名,一旦这个名 ...
- C++中函数的默认参数和C语言中volatile的学习
1.函数默认参数 1 int func(int a,int b=10) 2 { 3 return a*b; 4 } 5 6 int main() 7 { 8 int c=func(2); 9 cout ...
- C语言中qsort函数用法
C语言中qsort函数用法-示例分析 本文实例汇总介绍了C语言中qsort函数用法,包括针对各种数据类型参数的排序,非常具有实用价值非常具有实用价值. 分享给大家供大家参考.C语言中的qsort ...
- C语言中的static 详细分析
转自:http://blog.csdn.net/keyeagle/article/details/6708077/ google了近三页的关于C语言中static的内容,发现可用的信息很少,要么长篇大 ...
随机推荐
- remove duplicated gene pair using awk
cat input.txt TRINITY_DN106621_c0_g1_i1 TRINITY_DN129833_c0_g1_i2 TRINITY_DN106621_c0_g1_i1 TRINITY_ ...
- subroutines of perl
#!/usr/bin/perl -w @students = qw/Doreen Oskar Elin Sangeet Malin/; &next_student; &next_stu ...
- [bzoj4551][Tjoi2016][Heoi2016]树
Description 在2016年,佳媛姐姐刚刚学习了树,非常开心. 现在她想解决这样一个问题:给定一颗有根树(根为1),有以下两种操作: 1. 标记操作:对某个结点打上标记(在最开始,只有结点1有 ...
- Leetcode First Bad Version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the ...
- 【BZOJ-3757】苹果树 块状树 + 树上莫队
3757: 苹果树 Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 1305 Solved: 503[Submit][Status][Discuss] ...
- 【BZOJ-1086】王室联邦 分块 + 块状树
1086: [SCOI2005]王室联邦 Time Limit: 10 Sec Memory Limit: 162 MBSec Special JudgeSubmit: 1094 Solved: ...
- linux时间时区设置
用linux的时候大家可能会遇到时间不对,时区不对的情况.比如使用网上廉价的国外的linux的vps,时区是国外的.那么如何在不劳烦管理员的情况下自己动手呢?首先要了解硬件时钟与系统时钟,计算机上的B ...
- CF 701B Cells Not Under Attack(想法题)
题目链接: 传送门 Cells Not Under Attack time limit per test:2 second memory limit per test:256 megabyte ...
- java语言:Linux与JVM的内存关系分
在一些物理内存为8g的服务器上,主要运行一个Java服务,系统内存分配如下:Java服务的JVM堆大小设置为6g,一个监控进程占用大约 600m,Linux自身使用大约800m.从表面上,物理内存应该 ...
- 【项目】iOS - 使用UIWebView占用内存过大
通过其他博主介绍的解决这个问题的博客: http://blog.techno-barje.fr//post/2010/10/04/UIWebView-secrets-part1-memory-leak ...