C语言基础:获得当前日期和时间

2015-07-03 0 992
C语言基础:获得当前日期和时间
#include <stdio.h>
#include <time.h>
 
int main (void)
 {
   struct tm *gm_date;
 
   time_t seconds;
 
   time(&seconds);
 
   gm_date = gmtime(&seconds);
 
   printf("Current date: %d-%d-%d\n", gm_date->tm_mon+1,
     gm_date->tm_mday, gm_date->tm_year);
   printf("Current time: %02d:%02d\n", gm_date->tm_hour,
     gm_date->tm_min);
 
 
return 1;
 }

遇见资源网 c/c++ C语言基础:获得当前日期和时间 http://www.ox520.com/10265.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务