C++ How to declare pointer to 2D array -
this question has answer here:
i have portion of code goes (assume types int
):
for(int = 0; < h; ++i) { for(int = 0; < h; ++i) { if(...) { = b[i][j] } else { = c[i][j] } } }
i write check if
condition once. how go in declaring pointer 2d array adequately (variable d in example below) ?
if(...) { d = b; } else { d = c; } for(int = 0; < h; ++i) { for(int = 0; < h; ++i) { = d[i][j] } }
combining @madsciencedreams' answer , @grijesh chauhan comment, following seems work:
double a[1000][1000]; double (*b)[1000][1000] = &a;
and access value:
double = (*b)[i][j];
Comments
Post a Comment