#include <fstream>//文件读写头文件
#include <windows.h>
//写文件
void test01() {
//ofstream ofs("./test", ios::out | ios::trunc);
ofstream ofs;
ofs.open("./test", ios::out | ios::trunc);
if (!ofs.is_open()) {
cout << "打开失败" << endl;
}
ofs << "姓名:abc" << endl;
ofs << "年龄:100" << endl;
ofs << "性别:男" << endl;
}
//读文件
void test02() {
ifstream ifs;
ifs.open("./600917.txt", ios::in);
if (!ifs.is_open()) {
cout << "打开失败" << endl;
}
//第一种方式
//char buf[1024];
//while (ifs >> buf) {
// //按行读取
// cout << buf << endl;
//}<