11--2机器当前时间(time库函数)
来源:互联网 发布:下载picsart软件 编辑:程序博客网 时间:2024/06/05 16:46
本函数用于输出机器当前的时间
tim.h:头文件
#include<iostream.h>class tim{ public: tim();//构造函数,初始化数据成员 void print(); private: int year; int mon; int day; int hour; int min; int sec;};tim::tim(){ tm *local; time_t t;//time_t 类型 t=time(NULL); local=localtime(&t); year=local->tm_year+1900; mon=local->tm_mon+1; day=local->tm_mday; hour=local->tm_hour; min=local->tm_min; sec=local->tm_sec;}void tim::print(){ cout<<"机器当前时间:"<<endl <<year<<"年"<<mon<<"月"<<day<<"日" <<hour<<"时"<<min<<"分"<<sec<<"秒"<<endl;}
主函数:
#include <iostream>#include<time.h>#include"tim.h"using namespace std;int main(){ tim a; a.print(); return 0;}/*class Time{ public: Time();//构造函数,初始化数据成员 void print(); private: int year; int mon; int day; int hour; int min; int sec;};Time::Time(){ tm *local; time_t t; t=time(NULL); local=localtime(&t); year=local->tm_year+1901; mon=local->tm_mon+1; day=local->tm_mday; hour=local->tm_hour; min=local->tm_min; sec=local->tm_sec;}void Time::print(){ cout<<"机器当前时间:"<<endl <<year<<"年"<<mon<<"月"<<day<<"日" <<hour<<"时"<<min<<"分"<<sec<<"秒"<<endl;}*/
- 11--2机器当前时间(time库函数)
- TIME.得到当前时间
- C++11 获取系统时间库函数 time since epoch
- python time获取当前时间
- python使用 time.strftime() 命名文件名包含当前时间
- time(NULL)与GetLocalTime获取当前时间
- Linux C++显示系统当前时间 time
- python 取出当前时间详解 time
- time.setToNow() 取当前时间,月份有误
- time(NULL)与GetLocalTime获取当前时间
- python time模块获取当前时间
- 获取系统当前时间,Time过时
- 使用C的库函数获取当前本地时间
- 使用C的库函数获取当前本地时间
- 库函数(备忘)--time.h
- C time.h库函数
- 获取 当前时间的字符串 asctime localtime time
- python 利用time模块获取当前 日期时间
- Oracle PARTITION TABLE 分区表
- interface may not exist
- shiro安全三部曲
- java中io各种流的关闭顺序
- Linux
- 11--2机器当前时间(time库函数)
- SQL Server 触发器
- 谈谈对于企业级系统架构的理解
- JAVA IO操作总结——节点流和处理流
- 何用NSLog输出NSRange,CGRect等结构体
- 关于性能优化的一点总结
- cocos2d学习笔记第四章 粒子效果及座标系
- IIC总线协议
- 一个以前做的课设