本文介绍了ofstream错误在c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C ++中遇到一个流错误,这里是我的代码

  int main(){
ofstream myfile;
myfile.open(example.txt);
myfile<< 将此文件写入file.\\\
;
myfile.close();
return 0;
}



Dev-C ++ 10中的

错误

Thanks in advance

解决方案

You can try this:

#include <fstream>
using namespace std;

int main () {
  ofstream myfile;
  myfile.open ("example.txt");
  myfile << "Writing this to a file.\n";
  myfile.close();
  return 0;
}

这篇关于ofstream错误在c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 12:20