我正在编写一个关于具有链接表示的稀疏矩阵的程序。
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;
}
可能与23471161有关。它可能有助于发布更多代码,以及来自您最喜欢的调试软件的回溯输出。