ofstream 头文件是撒?

xengine-qyt 2009-10-11 04:17:10
是我写错了还是啥。

#include <fstream>



ofstream wstream("1.txt");
wstream.write("http://www.awdoawdnowa.com");
wstream.close();

为啥他提示 找不到 ofstream #include <fstream.h> 又说没有这个。
vc2008
...全文
5777 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiexianhui18 2010-04-08
  • 打赏
  • 举报
回复
去 下载ofstream.h的 头文件放 在 include文件夹里
xengine-qyt 2009-10-11
  • 打赏
  • 举报
回复
解决
woods2001 2009-10-11
  • 打赏
  • 举报
回复
使用名字空间
using namespace std;
或者
using std::ofstream
密斯刘 2009-10-11
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 aaadddzxc 的回复:]
。。。也试过 #include <fstream.h>

无法打开包括文件:“fstream.h”: No such file or directory
[/Quote]
实在抱歉 好久没用了 现在改过来 前面说的都不对
看代码 调试通过 VS2008 注意write函数有两个参数

#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream wstream("1.txt");
char site[] = "www.csdn.net";
wstream.write(site, sizeof(site));
wstream.close();
return 0;
}
mstlq 2009-10-11
  • 打赏
  • 举报
回复
#include <fstream>

using namespace std;
xengine-qyt 2009-10-11
  • 打赏
  • 举报
回复
。。。也试过 #include <fstream.h>

无法打开包括文件:“fstream.h”: No such file or directory
xengine-qyt 2009-10-11
  • 打赏
  • 举报
回复
恩 知道 但是我的却提示
error C2065: “ofstream”: 未声明的标识符

这是为啥呢
密斯刘 2009-10-11
  • 打赏
  • 举报
回复
补充 弄错了 是 fstream.h
密斯刘 2009-10-11
  • 打赏
  • 举报
回复
补充 弄错了 是 fstream.h
密斯刘 2009-10-11
  • 打赏
  • 举报
回复
#include <fstream>

文件流 即fstream

65,187

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧