W
Wei-Chao Hsu
There is an error in my program. The error message is
e:\test\test\main.cpp(9): error C2664: 'fun' : cannot convert parameter 1
from 'int [2][3]' to 'int ** '
If I change the argument "int** a" to "int a[2][3], it will be OK. But, I
don't want to change the definition.
How can I pass the matrix to the function?
//-------------------------------------------------------------
void fun(int **a,const int row,const int col);
void main()
{
int a[2][3];
fun(a,2,3);
}
void fun(int **a,const int row,const int col)
{
for(int i=0;i<row;++i)
for(int j=0;j<col;++j)
a[j]=i*10+j;
}
e:\test\test\main.cpp(9): error C2664: 'fun' : cannot convert parameter 1
from 'int [2][3]' to 'int ** '
If I change the argument "int** a" to "int a[2][3], it will be OK. But, I
don't want to change the definition.
How can I pass the matrix to the function?
//-------------------------------------------------------------
void fun(int **a,const int row,const int col);
void main()
{
int a[2][3];
fun(a,2,3);
}
void fun(int **a,const int row,const int col)
{
for(int i=0;i<row;++i)
for(int j=0;j<col;++j)
a[j]=i*10+j;
}