timer
来源:互联网 发布:网络销售成功案例 编辑:程序博客网 时间:2024/05/16 10:17
localtime.c
#include<stdio.h>
#include<time.h>
main()
{
time_t temp;
struct tm* p;
time(&temp);
p = localtime(&temp);
printf("year %d\n",p->tm_year+1900);
printf("month %d\n",p->tm_mon+1);
printf("day %d\n",p->tm_mday);
printf("hour %d\n",p->tm_hour);
printf("minute %d\n",p->tm_min);
printf("second %d\n",p->tm_sec);
printf("weekday %d\n",p->tm_wday);
}
time.c
#include<stdio.h>
#include<time.h>
int main()
{
time_t s;
s=time((time_t*)NULL);
printf("now %ld",s);
return 0;
}
gettime.c
#include<stdio.h>
#include<time.h>
main()
{
time_t temp;
struct tm* p;
time(&temp);
p = gmtime(&temp);
printf("year %d\n",p->tm_year+1900);
printf("month %d\n",p->tm_mon+1);
printf("day %d\n",p->tm_mday);
printf("hour %d\n",p->tm_hour);
printf("minute %d\n",p->tm_min);
printf("second %d\n",p->tm_sec);
printf("weekday %d\n",p->tm_wday);
}
ctime.c
#include<stdio.h>
#include<time.h>
int main()
{
time_t temp;
char *ti;
time(&temp);
ti=ctime(&temp);
printf("%s\n",ti);
return 0;
}
mktime.c
#include<stdio.h>
#include<time.h>
int main()
{
time_t temp1,temp2;
char *ti1, *ti2;
struct tm *p;
time(&temp1);
ti1=ctime(&temp1);
printf("%s\n",ti1);
p=gmtime(&temp1);
temp2=mktime(p);
ti2 = ctime(&temp2);
printf("%s\n",ti2);
return 0;
}
runtime.c
#include<stdio.h>
#include<time.h>
#include<sys/time.h>
#include<unistd.h>
int main()
{
struct timeval tv1,tv2;
struct timezone tz1,tz2;
long sec,usec,i;
gettimeofday(&tv1,&tz1);
for(i=1;i<1000;i++)
gettimeofday(&tv2,&tz2);
sec = tv2.tv_sec-tv1.tv_sec;
usec = tv2.tv_usec-tv1.tv_usec;
printf("%ld \n",1000000*sec+usec);
return 0;
}
inbetweenout.c
#include<stdio.h>
#include<time.h>
#include<sys/time.h>
#include<unistd.h>
int main()
{
struct timeval tv1,tv2;
struct timezone tz1,tz2;
int sec;
long usec,i;
gettimeofday(&tv1,&tz1);
printf("please input a int number\n");
scanf("%ld",&i);
gettimeofday(&tv2,&tz2);
sec = tv2.tv_sec-tv1.tv_sec;
usec = tv2.tv_usec-tv1.tv_usec;
printf("%d\n",sec);
printf("%ld \n",usec);
return 0;
}
asctime.c
#include<stdio.h>
#include<time.h>
int main()
{
time_t temp;
struct tm * p;
char *ti;
time(&temp);
p=gmtime(&temp);
ti=asctime(p);
printf("%s\n",ti);
return 0;
}
- timer
- Timer
- timer
- timer
- Timer
- Timer......
- timer
- TIMER
- TIMER
- TIMER
- timer
- Timer
- Timer
- timer
- timer
- Timer
- timer
- timer
- Hadoop Hive sql语法详解
- 解决mysql忘记密码
- API函数 postmessage 初探
- 模板页和内容页的运行机理
- LINQ标准查询操作符详解
- timer
- set和multiset
- linux服务器性能分析
- solaris 10 如何查看CPU的温度
- STL源码学习----lower_bound和upper_bound算法
- 各种手机或平板的外围器件datasheet的下载地址和相关介绍
- Android之TelephonyManager类的方法详解
- 关于TortoiseSVN的汉化
- 指针 示例剖析