使用getline函数的Seg fault()Multi 5编译器

时间:2013-05-09 14:02:56

标签: c++ getline

Iam使用Multi 5编译器并尝试使用getline函数访问受限内存时出错。请提出可能存在的问题。

anyfunction (std::string filePath)
{
    std:string linear = "";
    ifstream in;
    in.open(filePath);
    if(in.is_open())
    {
        while (getline(in,linear))  // <- get error here seg fault
        {
             do_someting();
        }
    }
    in.close
}

int main()
{
    std::string filePath = "\hello\asd.xml";
    anotherfunction(filePath);
    anyfunction(filePath); //working of both function is similar or they both use     getline
}

0 个答案:

没有答案