void print_matrix(double ** m, int rows, int cols)
{
for(int i = 0; i < rows; ++i)
{
for(int j = 0; j < cols; ++j)
{
cout << m[i][j] << '\t';
}
cout << endl;
}
}
int main()
{
double m[4][5] =
{
{2, 3, 4, 5, 6},
{1, 0, 0, 6, 0},
{0, 0, 2, 9, -6},
{9, 8, 7, 6, 5},
};
print_matrix(m, 4, 5);
return 0;
}
main.cpp:30:25: error: cannot convert 'double (*)[5]' to 'double**' for argument '1' to 'void print_matrix(double**, int, int)'
print_matrix(m, 4, 5);
^
So I think I understand what is wrong here however I would like to know how you would handle this. Do I need to use dynamic memory?