基于流的文件IO
头文件
ofstream : 写文件
ifstream : 读文件
fstream : 读写文件
[code]using namespace std;//打开文件std::ifstream fin("xxx.txt");//std::ifstream fin;//fin.open("xxx.txt");std::ofstream fout("xxxx.txt");if (!fin.is_open()) //判断文件是否打开成功{ cout ch; //read a character from the filechar buf[80];fin >> buf; //read a word from the filefin.getline(buf, 80); //read a line from the filestring line;getline(fin, line); //read from a file to a string objectfout |