我有一个以二维数组作为参数的函数。然后我有一个3d数组,例如temp[5][100][100]
。我想将此数组的2d部分传递给函数。我怎么能这样做?
int inteference_sets(int array[][],int array_size,int max_channel){
//function codes
}
int main(){
int k;
int temp[5][100][100];
for(k=1;k<=4;k++){
interference_sets(temp[k], , ) //this is how the program intends to work
}
}
有可能吗?如果是,那怎么办?
答案 0 :(得分:2)
#define DIM1 100
#define DIM2 100
int inteference_sets(int (*array)[DIM2], int array_size, int max_channel)
{
int row, col;
for( row = 0; row < array_size; row++ )
{
for( col = 0; col < DIM2; col++ )
{
int value = array[row][col];
//function codes
}
}
}
int main()
{
int k;
int temp[5][DIM1][DIM2];
for(k=1;k<=4;k++)
{
interference_sets(temp[k], DIM1, ) //this is how the program intends to work
}
}