c++ 打开文件总是File open error!

oubenruing 2011-07-27 06:59:01
这是代码

#include"fstream"
#include"sstream"
#include"iostream"
#include"string"
using namespace std;
void main()
{
ifstream file1;
file1.open("c:\1.txt");
if(file1.fail())
{
cout << "File open error!";
exit(1);
}
while(!file1.eof())
{
ostringstream oss;
char tmp[100];
file1.getline(tmp,100);
oss <<tmp<<"/t"<<"I love you"<<endl;
}
file1.close();
}


这是要打开文本文档的属性


我用的是win7 是不是跟用户权限有关? 还是什么的
顺便请帮我看看代码对不对 谢谢
...全文
708 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackyjkchen 2011-07-27
  • 打赏
  • 举报
回复
c:\\1.txt

c:/1.txt
oubenruing 2011-07-27
  • 打赏
  • 举报
回复
不知道为什么图片显示不出来````图片内容是 文档位置为c:无误````

33,311

社区成员

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

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