马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
基于流的文件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 |