请问我的C++读取文件代码哪里出了问题,为什么就是读不出来呢? 10
#include<iostream>#include<string>#include<fstream>usingnamespacestd;intmain(){string...
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main()
{
string inFile;
ifstream in;
cin>>inFile;
in.open(inFile.data());
if(!in.is_open())
{
cerr<<"open failed"<<endl;
exit(-1);
}
string line;
for(;;)
{
if(in.eof())break;
getline(in,line);
cout<<line<<"*********"<<endl;
}
return 0;
} 展开
#include<string>
#include<fstream>
using namespace std;
int main()
{
string inFile;
ifstream in;
cin>>inFile;
in.open(inFile.data());
if(!in.is_open())
{
cerr<<"open failed"<<endl;
exit(-1);
}
string line;
for(;;)
{
if(in.eof())break;
getline(in,line);
cout<<line<<"*********"<<endl;
}
return 0;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询