Pointer to an array of pointers
How to declare simply:
- pointer array? A pointer to a pointer does not mean anything. It is always a pointer to something (an object )
- pointer to array of pointers?
- table of pointers to arrays?
- Difference between pointer to an array and array of pointers?
Re: Pointer to an array of pointers
Use pointer to pointer integers :
Code:
#include <iostream.h>
int main()
{
// int * (arr *) [10]; this is not correct
int **aa; // use this trick
int k;
aa=new int*[3];
for(j=0;j<3;j++)
aa[j]=new int[4];
return 0;
}
Re: Pointer to an array of pointers
Pointer to an array of pointers :
Code:
# include <stdio.h>
# define N 3
int main (void)
(
/ * Array of pointers to char * /
char * t [N] = ( "RAM", "the", "C");
/ * P is a pointer to an array of pointers to char and
initialized at t above * /
char * (* p) [N] = & t;
int i;
for (i = 0; i <N; i + +)
printf ( "% s", (* p) [i]);
printf ( "\ n");
return 0;
)
Re: Pointer to an array of pointers
Pointer to an array :
Code:
# include <stdio.h>
# define N 3
int main (void)
(
int t [2] [N] = ((14, 19, 15), (21, 11, 2009));
int (* p) [N] = & t [1];
printf ( "% d \ n", (* p) [2]);
return 0;
)
Array of pointers to arrays :
Code:
# include <stdio.h>
# define N 3
int main (void)
(
int t0 [5] = (55, 33, 75, 21, 29);
int t1 [5] = (8, 23, 45, 54, 69);
/ * P is an array of 2 pointers to tables 5 int * /
int (* p [2]) [5];
/ * Test * /
p [0] = & t0;
p [1] = & t1;
printf ( "% d% d \ n", (* p [0]) [3], (* p [1]) [4]);
return 0;
)