65.9K
CodeProject is changing. Read more.
Home

Declare a reference for a two dimensional array without typecasting

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Jan 3, 2012

CPOL
viewsIcon

7550

The second form is wrong. A two dimensional pointer does not equal to a two dimensional array. But you can use an one dimensional pointer to reference the two dimensional array.int arr[1][20];int *pTwoDem=(int*)arr;Now you can use *(pTwoDem+10) to replace arr[0][10].

The second form is wrong. A two dimensional pointer does not equal to a two dimensional array. But you can use an one dimensional pointer to reference the two dimensional array.

int arr[1][20];
int *pTwoDem=(int*)arr;

Now you can use *(pTwoDem+10) to replace arr[0][10].