Re: array pointer
"Michal Nazarewicz" <[email protected]> Tue, 18 Jan 2011 15:46:48 +0100
| Newsgroups | org.kernel.vger.linux-c-programming |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 18 Jan 2011 14:32:43 +0100, ratheesh k <[email protected]> wrote: > int *s_ptr; > int **d_ptr; > int arr[2][2]={1,2,3,4}; One image is worth a thousand words, so here it goes: arr is something like this in memory: +---+---+---+---+ | 1 | 2 | 3 | 4 | +---+---+---+---+ d_ptr would require something like: +---------+---------+ | pointer | pointer | +----|----+----|----+ | | +---+---+ | +---> | 3 | 4 | | +---+---+ +---+---+ +---> | 1 | 2 | +---+---+ Ie. in arr all the numbers are lied linearly in memory whereas int **d_ptr is an array of pointers to array of ints.