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
}