求大神解决啊,C++程序里用ignore为什么读出来是空的

这是程序:
#include<iostream>
#include<fstream>
#include<string>

using namespace std;

int main()
{
string fileName,a,b,c;
ifstream inFile;

cout<<"please input the fileName"<<endl;
cin>>fileName;
inFile.open(fileName.c_str());
inFile.ignore(200,',');
inFile>>a;
inFile.ignore(200,',');
inFile>>b;
inFile.ignore(200,',');
inFile>>c;

cout<<a<<endl<<b<<endl<<c<<endl;

inFile.close();

return 0;
}
我要读取一个文本文档中的东西:the,dog,disk,boom.break,build。要忽略逗号以及逗号前的东西

#include<iostream>
#include<fstream>
#include<string>

using namespace std;

int main()
{
string fileName,a,b,c;
ifstream inFile;

cout<<"please input the fileName"<<endl;
cin>>fileName;
inFile.open(fileName.c_str());
// if(not inFile.is_open()){
//    std::cerr<<"unable to open the file";
//    while(1);
//    return 0;
// }
inFile.ignore(200,',');
inFile>>a;
inFile.ignore(200,',');
inFile>>b;
inFile.ignore(200,',');
inFile>>c;

cout<<a<<endl<<b<<endl<<c<<endl;

inFile.close();

return 0;
}

追问

不行啊,输出还是空的。。

追答#include<iostream>
#include<fstream>
#include<string>
 
using namespace std;
 
int main()
{
    string fileName,a,b,c;
    ifstream inFile;
 
    cout<<"please input the fileName"<<endl;
    cin>>fileName;
    inFile.open(fileName.c_str());
    if(not inFile.is_open()){
        std::cerr<<"unable to open the file";
        while(1);
        return 0;
    }else{
        std::cerr<<"the file is successfully opened";
    }
 
    inFile.close();
 
    return 0;
}

看输出是什么

追问

程序有一个错,不能运行

温馨提示:答案为网友推荐,仅供参考
相似回答