I took a hiatus from C and am just getting back into it again.
If I want to create a 2D array of doubles, I can do it two ways:
double** m_array = (double**) malloc(2*sizeof(double*));
double* m_array = (double*) malloc(2*sizeof(double));
OR
double array[2][2];
But, when I wish to pass the malloc'd array versus passing the other, there seems to be two conventions:
//allowed for passing in malloc'd array, but not for other array
func_m(m_array) //allowed
func_m(array) //disallowed
func_m(double** m_array)
//allowed for passing in either array; required for passing in non-malloc'd array
func(m_array) //allowed
func(array) //allowed
func(double array[][2])
In the first, I don't need any information beyond that it is a pointer to an array of pointers. But it can only be a malloc'd array.
In the second, I need to pass the length of each array that the array of double* points to. This seems silly.
Am I missing something? Thanks in advance.