#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
int main(int argc, char** argv)
{
// typedef long time_t
time_t a;
struct tm *b;
a = time(NULL);
// struct tm *localtime(const time_t *timep);
// time_t 2 tm
b = localtime(&a);
// char *ctime(const time_t *timep);
// time_t 2 string
printf("%s(%d):(ctime time_t 2 string):%s\n", __FILE__, __LINE__, ctime(&a));
// char *asctime(const struct tm *tm);
// tm 2 string
printf("%s(%d):(localtime tm 2 string):%s\n", __FILE__, __LINE__, asctime(b));
return 0;
}
time_t,tm结构体,以及与string之间的转换函数
最新推荐文章于 2023-04-20 09:42:44 发布