I am trying this code:
int x[] = {1,5};
int y[] = {3,6};
int *w[] = {x,y};
int **z = w;
printf("%d", **z[1]);
cout<<**z[0];
But it doesn't work. My goal is to access to each element inside the x or y arrays. My question comes from this part of a really OpenCV code:
float h_ranges[] = {0, 180};
float s_ranges[] = {0, 256};
const float* ranges[] = {h_ranges, s_ranges};
And like to know how is it possible to read each element inside ranges[]?
EDIT: I tryed:
printf("%d", z[1][1]);
cout<<z[0][0];
And it worked, but it's interesting for me to know why
printf("%d", **z[1][1]);
cout<<**z[0][1];
Doesn't work, but the following code works
printf("%d", *w[1]);
cout<<*w[0];
What is the difference between w and z here?
EDIT2:
Why the result of
printf("%d", *w[1]);
cout<<*w[0];
Is same as the result of:
printf("%d", *z[1]);
cout<<*z[0];
z[1][1]is? If yes why do you think that adding two "stars" at the front is allowed?*w[0]and*z[0]have same result? In fact I can not imagine truly the structure ofzat this point!