【发布时间】:2019-09-02 07:33:59
【问题描述】:
在矩阵中输入数字时的断言问题
我已经检查了矩阵是否已正确分配
matrix = alloc_matrix(row, cols);
printf("enter number to matrix\n");
int i, j;
for (i = 0; i < row; i++)
{
for (j = 0; j < cols; j++)
{
scanf_s("%d", matrix[i][j]);
}
}
void main() {
int row, cols;
int **matrix;
printf("pleaese enter a row \n");
scanf_s("%d", &row);
printf("pleaese enter columns\n");
scanf_s("%d", &cols);
matrix = alloc_matrix(row, cols);
printf("enter number to matrix\n");
int i, j;
for (i = 0; i < row; i++) {
for (j = 0; j < cols; j++) {
scanf_s("%d", matrix[i][j]);
}
}
system("pause");
}
断言失败
【问题讨论】:
-
alloc_matrix是什么?其他代码在什么功能中?它在哪里失败了断言?请发布整个代码,或者更确切地说是Minimal, Reproducible Example