C++编程便捷口

 

 

获取当前时间

 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 }

 

转载于:https://www.cnblogs.com/yangwithtao/p/10302049.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值