首页 > 编程语言 > 详细

C++编程便捷口

时间:2019-01-22 10:39:34      阅读:201      评论:0      收藏:0      [点我收藏+]

 

 

获取当前时间

 1 #include <iostream>
 2 #include <ctime>
 3 #include <stdlib.h>
 4 #include <stdio.h>
 5 
 6 using namespace std;
 7 
 8 string  Get_Current_Date();
 9 
10 int main( )
11 {
12     // 将当前日期以 20** - ** - ** 格式输出
13     cout << Get_Current_Date().c_str() << endl;
14 
15     getchar();
16     return 0;
17 }
18 
19 string  Get_Current_Date()
20 {
21     time_t nowtime;  
22     nowtime = time(NULL); //获取日历时间   
23     char tmp[64];   
24     strftime(tmp,sizeof(tmp),"%Y-%m-%d %H:%M:%S",localtime(&nowtime));   
25     return tmp;
26 }

 

 

 

判断文件是否存在

 1 fstream _file;
 2 _file.open(FILENAME,ios::in);
 3 if(!_file)
 4 {
 5  cout<<FILENAME<<"没有被创建";
 6 }
 7 else
 8 {
 9   cout<<FILENAME<<"已经存在";
10 }

 

C++编程便捷口

原文:https://www.cnblogs.com/yangwithtao/p/10302049.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!