Receive a two-dimensional array as a function
void myFunction(double** myArray){
myArray[x][y] = 5;
etc...
}
There's a function like this
double anArray[10][10];
myFunction(anArray)
I'm getting an error because I'm using it together.
Since the array name is a pointer, isn't anArray
a double**
type?
Why is it only on my computer when other people are good at passing 2D arrays?
anArray[10];
anArray
in double[10];
is not a double**
type, but a double[10][10]
type.
To receive a two-dimensional array as a function factor, you must match the following types:
int array[10][10];
void passFunc(int a[][10])
{
// ...
}
passFunc(array);
int *array[10];
for(int i = 0; i < 10; i++)
array[i] = new int[10];
void passFunc(int *a[10]) //Array containing pointers
{
// ...
}
passFunc(array);
int **array;
array = new int *[10];
for(int i = 0; i <10; i++)
array[i] = new int[10];
void passFunc(int **a)
{
// ...
}
passFunc(array);
© 2024 OneMinuteCode. All rights reserved.