回顾下C++里的文件流操作
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char ** argv)
{
// Firstly, we write to file
string sName = "MyName";
int nAge = 20;
char cGender = 'M';
ofstream out("example.dat", ios::binary);
out<<sName<<" "<<nAge<<" "<<cGender<<" ";
out.close();
// Secondly, we read file
string sName1;
int nAge1;
char cGender1;
ifstream in("example.dat", ios::binary);
in>>sName1>>nAge1>>cGender1;
in.close();
// Finally, we output data
cout<<sName1<<" "<<nAge1<<" "<<cGender1<<endl;
return 0;
}