当前位置:
首页 >
C++ 文件写操作
发布时间:2025/3/15
40
豆豆
#include <fstream>
#include<iostream>
using namespace std;void test01(){ofstream ofs;ofs.open("test.txt",ios :: out);ofs << "姓名:张三"<< endl;ofs << "性别:男"<< endl;ofs << "年龄: 18" << endl;ofs.close();
}
int main() {test01();system(" pause");
}
这个就是文件的内容,默认写进和这个cpp同一层路径
总结
- 上一篇: 链表队列出队算法
- 下一篇: C++ 类和对象成员特性