C++简易文件操作源代码
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
char szWrite[] = "Hello, I love my baby!";
char szRead[100] = "/0";
int nLen = strlen(szWrite);
ofstream ofs("andylin.txt");
ifstream ifs("andylin.txt");
ofs.write(szWrite, nLen);
ofs.flush();
ofs.close();
ifs.read(szRead, 100);
cout << "szRead = " << szRead << endl;
return 0;
}