You can point it to the first y position.
int *p = numbers[0];
Or whichever one you want.
twomers
Posting Virtuoso
1,877 posts since May 2007
Reputation Points: 453
Solved Threads: 57
Examples
int numbers[4][2];
int (*p)[2] = numbers;
(*p)[0] = 0; // numbers[0][0] = 0;
p++; // move to next row
(*p)[0] = 0; // numbers[1][0] = 0;
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Take a look at this:
int main() {
int numbers[4][4] = { { 0, 1, 2, 3 },
{ 4, 5, 6, 7 },
{ 0, 9, 8, 7 },
{ 6, 5, 4, 3 } };
int (*p)[4] = numbers;
(*p)[0] = 42;
p++;
(*p)[3] = 63;
for ( int y=0, x; y<4; y++ ) {
for ( x=0; x<4; x++ )
std::cout<< numbers[y][x] << " ";
std::cout<< "\n";
}
return 0;
}
twomers
Posting Virtuoso
1,877 posts since May 2007
Reputation Points: 453
Solved Threads: 57