-1
我想乘上矩陣。我通過malloc()
函數創建矩陣。指數(命名爲i
變量)顯示NULL
,而不是數量索引在循環內顯示NULL
int** matrix_a = (int**)malloc(lines * sizeof(int*));
for (int i = 0; i < lines; i++) {
if (i == NULL)
printf("'i' is NULL!");
matrix_a[i] = (int*)malloc(trans * sizeof(int*));
}
輸出:
'i' is NULL!
錯誤:
Unhandled exception at 0x00007FF6003C35BB in MPI_C.exe: 0xC0000005: Access violation writing location 0xFFFFFFFFABA57A00.
你想用'i == NULL'完成什麼? – pzaenger
乾淨的語言將不勝感激。 –
不要施加'malloc()'的結果。 – melpomene