C++ Code Snippet (1)
时间:2010-10-07 来源:AnswerYi
C++ File Operation 1
2 void FileHandle(string name,string outfile)
3 {
4 ifstream in(name.c_str());
5 ofstream out(outfile.c_str());
6
7 if(in) {
8
9 out << in.rdbuf();
10
11 }
12 in.close();
13 out.close();
14 }
------------------------------------
时间
#include<time.h>
time_t t = time(NULL);
cout << ctime(&t);
// Thu Oct 07 12:16:08 2010
-------------------------------------
字符串
#include<string>
string str;
assign(string);append();
c_str();
find_first_of();
substr(int start,int len);
--------------------------------------
目录操作
#include<io.h>
_finddata_t data;
long handle = _findfirst(“”,&data);
相关阅读 更多 +