Ofstream在Dev C++中不起作用.不知道为什么
Ofstream is not working in Dev C++. Any idea why not?
我正在用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 ();
相关文章:
- 我的神经网络不起作用 [XOR 问题]
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- C++为什么尽管我调用了void函数,它却不起作用
- 为什么在保护模式下继承升级不起作用
- 我正在努力在随机数组中查找最小值,有人知道为什么我的代码不起作用?C++
- 我的Arduino串行命令行不起作用,我不知道为什么
- 我正在编写一个拆分为 3 的合并排序,我不知道为什么它不起作用
- VS为我提供了对构造函数的另一个解决方案,但我想知道为什么我的工作不起作用
- C ++我不知道为什么这个迭代器在我的代码中不起作用
- cin.clear() 不起作用 - 不读取输入
- 有谁知道为什么这段代码不起作用
- 循环工作/不起作用,不知道为什么C++
- Ofstream在Dev C++中不起作用.不知道为什么
- 字符串下标超出范围.我不知道如何使用字符索引数组,所以我使用了(无符号整数),但它不起作用
- 如果向量包含重复项,则此函数应返回 true。知道为什么它不起作用吗?
- .cpp文件的组合框Scopes和Function in Scope在VS2008 sp2中不起作用.知道为什么这些组合
- 我的加载图像不起作用 - 我需要知道为什么
- C++ if 语句不起作用(不会读取内存)
- Visual Studio Designer在VS2012中不适用于C++/CLI文件,而在VS2005中则不起作用。知道为什么吗?