C++写入文件一例,语法上比JAVA要简单多了。
class="cpp" name="code">#include <fstream> using namespace std; int main() { ofstream outFile; // 在D盘下新建text.txt文件 outFile.open("D:\\test.txt"); outFile << "this is a c++ file write test."; outFile.close(); return 0; }
?