In C++, We can do the following:
#include <iostream>
int main()
{
int arr[] = {1,2,3};
int *p = arr;
return 0;
}
However this dosen't seem to work:
#include <iostream>
int main()
{
int arr[][3] = {{1,2,3},{4,5,6}};
int **p = arr;
return 0;
}
Can somebody please explain me why it does not work for 2d arrays.
Also when dealing with pointers and 2d arrays, consider the following code:
#include <iostream>
int N = 5;
void func(int arr[][N]){
return;
}
int main()
{
int arr[N][N];
return 0;
}
The above code doesn't work either and i don't know why? Error: expression must have a constant value (Variable N)