c++ 时间函数和结构化数据

    time和localtime
    数据结构概念
    struct关键字
    认识数据结构
    自定义结构

例:获取当前系统日期和时间;(代码例子)
     
    
一、函数: time
   函数time()返回的是当前时间(确切的来说这么说是不正确的,其实time返回的是从格林威治时间1970年1月1日0点0分0秒到现在的秒数)
二、函数: localtime
    功 能: 把从1970-1-1零点零分到当前时间系统所偏移的秒数时间转换为日历时间 。 
    说明:此函数获得的tm结构体的时间,是已经进行过时区转化为本地时间。  
    用 法: struct tm *localtime(const time_t *clock);   
    返回值:返回指向tm 结构体的指针.tm结构体是time.h中定义的用于分别存储时间的各个量(年月日等)的结构体.
    
三、struct关键字    
struct tm {
        int tm_sec;     /* seconds after the minute - [0,59] */ 秒数
        int tm_min;     /* minutes after the hour - [0,59] */int tm_hour;    /* hours since midnight - [0,23] */int tm_mday;    /* day of the month - [1,31] */int tm_mon;     /* months since January - [0,11] */int tm_year;    /* years since 1900 */int tm_wday;    /* days since Sunday - [0,6] */ 周一至周日
        int tm_yday;    /* days since January 1 - [0,365] */ 
        int tm_isdst;   /* daylight savings time flag */
            };
    
四、 数据结构可以认为是相互之间存在一种或多种特定关系的数据元素的集合。

五、自定义结构:
例:如果某学校需要记录当天学生到校的时间;(精确到 时分)
 struct mytime
{
  int 时;
  int min;
}stu[2];
    
原文地址:https://www.cnblogs.com/whzym111/p/6125976.html