✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
int **matrix = (int**) calloc(rows, sizeof
(int*));
if(!matrix)
{
printf("MEMORY_ALLOCATION_ERROR_MESSAGE");
exit(-1);
}
for (int i = 0; i < rows; ++i) {
matrix[i] = (int*) calloc(cols, sizeof
(int));
if(!matrix[i])
{
printf("MEMORY_ALLOCATION_ERROR_MESSAGE");
exit(-1);
}
}
return matrix;
}
A függvény idő és térbeli hatékonysága: