获取系统时间显示或存入数组中

把时间存入数组中 

#include<time.h>
#include <string.h>


int main()
{
	//获取系统时间并把时间存到数组中
	time_t  t;
	char  buf[128];
	memset(buf,0,sizeof(buf));
	struct tm *tmp;
	t = time(NULL);
	tmp = localtime(&t);
	strftime(buf,sizeof(buf),"%Y-%m-%d %H:%M:%S",tmp);
        
        return 0;
}

显示时间

#include<time.h>
#include <string.h>
#include<stdio.h>

int main()
{
    time_t t;
    struct tm * st;
    time (&t);//获取系统时间
    st = localtime (&t);
    printf ( "%d/%d/%d %d:%d:%d\n",st->tm_year+1900, st->tm_mon, st->tm_mday, st->tm_hour, st->tm_min, st->tm_sec);//输出结果

    return 0;
}

链接动态库 

 gcc main.c -I /new_lib/include -lsqlite3 -L /new_lib/lib        /new_lib/include  为库所在位置

静态库

 arm-linux-gcc test.c -lfont -L.                  .  为当前路径

猜你喜欢

转载自blog.csdn.net/weixin_41215479/article/details/84566977
今日推荐