C++ 文件写操作
#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同一層路徑
總結
- 上一篇: 链表队列出队算法
- 下一篇: 复习1 - String,StringB