I want to know if I can declare a function like this.

void doublmatrix(int **x, int **y, int N, int M)

I have seen functions declare like this before, but I am having trouble with that since the number of column needs to be specified.

I received an error message said that "can not convert int (*) [3] to int **".

Here a sample code below, I want to take the transform of an image. This is not the actual code, but use for simplification. It also gave me the same error message.

The code work when I declare it like this: void doublematrix(int x[][3], int y[][3], int N, int M). I also want to know if a function can declare like this void doublematrix(int x[N][M], int y[N][M], int N, int M) or void doublematrix(int x[N][M], int y[N][M], const int N, const int M).

Finally, another problem that I want to solve is declare the function like this

void doublematrix(int **x, int **y), and use the sizeof to determine the number of element. I did it like that for a simple matrix and it works. I don't know if I did it right. This is the first time I have been playing with these stuffs.

I will appreciate any help.

//*************************************

int i, j, k; //k is tne number or raw, j the number of colunm

i = (unsigned char)sizeof(a);

j = (unsigned char)sizeof(a[0]);

k = i/j;

//*****************************

#include <stdio.h>

#include <conio.h>

void doublematrix(int **x, int **y, int N, int M);

void main()

{

int x[3][3] = {{0,1,2},

{3,4,5},

{6,7,8}};

int n,k;

const int N = 3;

const int M = 3;

int y[N][M];

doublematrix(x,y,N,M);

for (n=0;n<N;n++)

{

for (k=0;k<M;k++)

{

printf("%d ", y[n][k]);

}

}

getch();

}

void doublmatrix(int **x, int **y, int N, int M)

{

int n;

int k;

for (n=0;n<N;n++)

{

for (k=0;k<M;k++)

{

y[n][k] = 2*x[n][k];

}

}

}

>>int (*) [3] to int **".

Why don't you simply use a typecast, e.g.

doublematrix( (int**) x, (int**) y,N,M);

?