我正在尝试将文件中的值读取到此矩阵**a,但我总是Segmentation fault
因为我的scanf
. 你能解释一下我的错误吗?谢谢
int main(int argc, char**argv) {
int**a;
FILE * fp;
int i, j, temp;
int n = 8;
fp = fopen("matrix.txt", "r");
a = malloc(sizeof(int)*n);
for (i = 0; i < n; i++)
a[i] = malloc(sizeof(int)*n);
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
fscanf(fp, "%d", a[i][j]);
return 0;
}