2 dim numbers..
-
int* pInt = new int[2*3]; 6 elements So you can access it like pInt[0],1,2,.. now i want to acess it as a 2dim. for example, 0 1 2 3 4 5 Or 0 1 2 3 4 5 i have declared a pointer like int (*pintPtr)[2][3]; Now how do I assign this to pInt? something like , pintPtr=((int*)[2][3])&pInt;? This do not work. Please help.
---------------------------- 286? WOWW!:-O
-
int* pInt = new int[2*3]; 6 elements So you can access it like pInt[0],1,2,.. now i want to acess it as a 2dim. for example, 0 1 2 3 4 5 Or 0 1 2 3 4 5 i have declared a pointer like int (*pintPtr)[2][3]; Now how do I assign this to pInt? something like , pintPtr=((int*)[2][3])&pInt;? This do not work. Please help.
---------------------------- 286? WOWW!:-O
void main()
{
int (*p)[3] = new int[2][3];
int i, j;
for(i = 0; i < 2; i++) {
for(j = 0; j < 3; j++) {
p[i][j] = i +j;
}
printf("\n");
}
int (*pX)[3] = p;
for(i = 0; i < 2; i++) {
for(j = 0; j < 3; j++) {
printf("%d ", pX[i][j]);
}
printf("\n");
}
printf("\n");
for(i = 0; i < 2; i++, pX++) {
for(j = 0; j < 3; j++) {
printf("%d ", (*pX)[j]);
}
printf("\n");
}
delete [] p;
}
Maxwell Chen