C++文件写

#include <iostream>
#include <fstream>

int main()
{
   using namespace std;

   ofstream ofs;
   ofs.open("test.txt", ios::out);
   ofs << "hello furong" << endl;
   ofs << "i love y" << endl;
   ofs.close();

   return 0;
}
$ ./a.out      
$ cat test.txt 
hello furong
i love y
posted @ 2022-07-12 15:11  thomas_blog  阅读(22)  评论(0编辑  收藏  举报