Is it possible to pass 2D arrays as a parameter without knowing the size? The effect I'm trying to get is:
void print(double a[][], int row, int col){//Print 2D array}
That way I can just make a method that works with different sizes. I was thinking of using pointers to get around needing to set a size, but I'm not sure how to go about it. So, is there a way to do this:
void print(double **a, int row, int col){//Print 2D array}
Those two functions are in fact, identical. Arrays passed to functions are automatically converted to pointers. The method you are showing would be a standard way to handle an array passed as a parameter...though wouldn't you want this function to be a method of your matrix class, and have it print the internal array?
Yeah, I had it implemented as a class method, but I just wanted to see if I can rewrite print just to test out pointers. I still can't seem to get it to work. If I use the second function, it doesn't work with my 2D array.
1 2
double A[2][2] = {{1, 2}, {2, 3}}
print(A, 2, 2);
It gives me an error. "cannot convert parameter 1 from 'double [2][2]' to 'double **"