获取当前的时间,转化为char[]格式unix时间戳

 1 /*
 2 
 3 在这个程序当中实现获取当前的unix时间戳
 4 转化为char[]
 5 */
 6 #include<stdio.h>
 7 #include<stdlib.h>
 8 #include<time.h>
 9 void main()
10 {
11     //获取当前的时间戳
12     time_t s;
13     s=time(NULL);
14     printf("%ld\n",s);
15     char a[20];
16     //转化为char[]
17     snprintf(a,20,"%ld",s);
18     printf("%s\n",a);
19 }

 

posted @ 2013-09-11 16:55  yufenghou  阅读(238)  评论(0编辑  收藏  举报