Ofstream在Dev C++中不起作用.不知道为什么

Ofstream is not working in Dev C++. Any idea why not?

本文关键字:不起作用 不知道 为什么 C++ Dev Ofstream      更新时间:2023-10-16

我正在用C++处理我的第一个文件。我已经写了一个简单的程序,但问题是流现在正在DevC++中工作。有什么建议吗?

#include<iostream>
#include<fstream>
#include<string>
using namespace std;

int main(){
ofstream file_;
file_.open("mytext.txt");
file_ << "This is my first text file ";

file.close();
std::cin.get();
 return 0;
}

正如mindriot在评论中所说,这是一个编译错误,请使用:

file_.close ();
相关文章: