请教:文件的打开

machaoqun6666 2008-08-21 12:51:24
ifstream file;
file.open("c:/用户/hp/AppData/Roaming/Cyberlink/PowerStarter/5.5/Profile.ini ",ifstream::in);
if(!file)
cout<<"aaaaa"<<endl;
为什么打不开文件?总输出aaaaa
...全文
76 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangdeqie 2008-08-21
  • 打赏
  • 举报
回复
路径直接粘贴地址栏的地址,再把'\'换成'/'即可
caohaiming 2008-08-21
  • 打赏
  • 举报
回复
楼主,你要确定c:/用户/hp/AppData/Roaming/Cyberlink/PowerStarter/5.5/Profile.ini 下有Profile.ini文件,要包含头文件
#include <iostream>
#include <fstream>
using namespace std;
我试验了你的代码,可以打开文件
另外附一个MSND的例子

// ios_base_openmode.cpp
// compile with: /EHsc
#include <iostream>
#include <fstream>

int main ( )
{
using namespace std;
fstream file;
file.open( "rm.txt", ios_base::out | ios_base::trunc );

file << "testing";
}
caohaiming 2008-08-21
  • 打赏
  • 举报
回复
楼主,你要确定c:/用户/hp/AppData/Roaming/Cyberlink/PowerStarter/5.5/Profile.ini 下有Profile.ini文件,要包含头文件
#include <iostream>
#include <fstream>
using namespace std;
我试验了你的代码,可以打开文件
另外附一个MSND的例子

// ios_base_openmode.cpp
// compile with: /EHsc
#include <iostream>
#include <fstream>

int main ( )
{
using namespace std;
fstream file;
file.open( "rm.txt", ios_base::out | ios_base::trunc );

file << "testing";
}
taojian_hhu 2008-08-21
  • 打赏
  • 举报
回复
file.open("c:/用户/hp/AppData/Roaming/Cyberlink/PowerStarter/5.5/Profile.ini ",ios::in);

33,322

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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