这个例子利用了C++文件读写的功能,将main()函数输出到一个记事本中

#include<fstream>
#include<iostream>

using namespace std;

int main()
{
fstream fin,fout;
fin.open("main.cpp",ios::in);
if(!fin)
{
cout<<"can't open file main.cpp !";
return -1;
}
fout.open("main.txt",ios::out);
if(!fout)
{
cout<<"can't open file main.txt !";
return -1;
}
char ch;
while(fin.get(ch))
fout.put(ch);
fin.close();
fout.close();
return true;
}


程序将自己的源代码写入记事本

相关文章:

  • 2021-12-07
  • 2022-02-16
  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
猜你喜欢
  • 2022-12-23
  • 2021-09-14
  • 2021-08-21
  • 2021-12-14
  • 2022-01-09
  • 2021-11-27
相关资源
相似解决方案