malloc函数问题:检测到严重错误c0000374

问题描述 投票:0回答:1

我正在编写一个关于具有链接表示的稀疏矩阵的程序。

temp =(matrixPointer *)malloc(sizeof(matrixPointer));

但是每当我像上面的malloc一样使用临时指针时,它会检测到错误并停止。如果我有少于3个输入,那就没关系,但是当它变为3或更多时会出错。为什么会这样?它只表示检测到严重错误c0000374。

这是我的代码的一部分。

for (i = 0; i < numTerms; i++) {
            printf("Enter row, column and value: ");
            scanf("%d%d%d", &row, &col, &value);
            if (row > currentRow) {
                last->right = hdnode[currentRow];
                currentRow = row; last = hdnode[row];
            }
            temp = (matrixPointer*)malloc(sizeof(matrixPointer));
            temp->tag = entry; temp->u.entry.row = row;
            temp->u.entry.col = col;
            temp->u.entry.value = value;
            last->right = temp;
            last = temp;
            hdnode[col]->u.next->down = temp;
            hdnode[col]->u.next = temp;
        }
sparse-matrix heap-corruption
1个回答
0
投票

可能与23471161有关。它可能有助于发布更多代码,以及来自您最喜欢的调试软件的回溯输出。

© www.soinside.com 2019 - 2024. All rights reserved.