+ -
当前位置:首页 → 问答吧 → 一个ifstream 打开文件的错误

一个ifstream 打开文件的错误

时间:2011-12-12

来源:互联网

C/C++ code

void bayes()
{
    ifstream infile("ls-train.txt");
    ifstream input;
    if(!infile)
    {
        cout <<  "dict open error "<<endl;
    }
    string word;
    string filename;
    char *temp = (char *)malloc(sizeof(char)  * 10) ;
    int i = 1;
    int type;

    /*这一步  是统计每一分类 ,他每个单词出现的次数*/
    while(infile >>  filename)
    {
        //strcpy(temp,filename.c_str()) ;
        //type = temp[0] - '0';
    [color=#FF0000]    input( filename.c_str() );  //这一步报错 : no match for call to ‘(std::ifstream) (const char*)[/color]
        if( ! input) ;
            cout << filename << " open error" << endl;
   

        input.close();
    }
    infile.close();




请大牛指教

作者: fx397993401   发布时间: 2011-12-12

没有你那样的函数调用...
input( filename.c_str() ); // input是一个对象,你这样写,不知是什么含义?

作者: yaningfan   发布时间: 2011-12-12