无法找到未处理异常的原因

时间:2013-04-25 13:43:42

标签: c++ parsing exception iostream

我正在为.obj文件编写一个解析器,并且在这个代码块的for循环中抛出了一个未处理的异常,我无法找到它。 visual studio错误消息说它在ntdll.dll。然后代码在ostream文件中中断。当我使用断点时,程序在相当多的迭代之前不会崩溃。

//Intitialising index array for that part and returning to the start of the 
vertex defining period
//iCount is the number of indices that are being read in
//Position is the saved position within the .txt file that has been reached
data[k].indices = new triangle[iCount];
data[k].noIndices = iCount;
data[k].verTex = new point3D[iCount];

int a,b,c,d,e,f;

int check = 0;
inFile.seekg(position - 1);

cout << "Icount" << iCount << endl;

//Getting index data
for(int j = 0; j < iCount; j++)
{
    char buff[40];
    inFile.getline(buff, 40);
    int matched = sscanf(buff, "f %d/%d %d/%d %d/%d", &a, &b, &c, &d, &e, &f);

    //Zero align the indices and store the data
    data[k].verTex[j].x = b - 1;
    data[k].verTex[j].y = d - 1;
    data[k].verTex[j].z = f - 1;

    //Zero align the indices and store the data
    data[k].indices[j].a = a - 1;
    data[k].indices[j].b = c - 1;
    data[k].indices[j].c = e - 1;
}

编辑:添加此代码块后, fail 将写入控制台,直到堆损坏。这是因为如果没有断点运行,sscanf()在第一次迭代后返回-1

if(matched != 6)
{
    cout << "fail";
}

0 个答案:

没有答案