|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#16
|
|||||
|
|||||
|
Quote:
Quote:
Quote:
is a declaration and initialization at the same time. So let's break it down to make it simplier: int (*pArr2d)[3]; // this makes pArr2d a pointer to type X (X = arrray of 3 ints) pArr2d = Arr2d; // set the address of pArr2d to the address of Arr2d, duh. pArr2d[0] is using a pointer in array-style accessing. Take a look at this first: int *pint; int array[10] = {0,1,2,3,4,5,6,7,8,9}; pint = array; // pint = &array[0]; pint[5] accesses the 6th value in array[]. To the compiler, it is exactly the same as array[5], or *(pint+5), or *(array+5). They are all the same, since pointers and arrays are the same. This is why pint = array works, and you don't need to use pint = &array[0] syntax. Okay, going back to: pArr2d[0] It is accessing the 1st element of Arr2d, which is the first X in the array. What is the first X? X is an array of 3 ints, so the first X is the first array of 3 ints - otherwise, the first 'row' of the 2D array. I hope that explanation helps...
__________________
Jason Doucette / Xona.com™ - Programming Windows Errata Addendum "Discussion is an exchange of knowledge; argument is an exchange of ignorance." |
|
#17
|
|||
|
|||
|
Sorry, I didn't mean I didn't understand. I got it the first time. Thanks.
|
|
#18
|
||||
|
||||
|
Oh, ok, no problem.
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > array containing arrays pointer incrementing? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|