About pointers in C -
I have started reading some articles about pointers in C and I have found an example that I can not understand I am here. / P>
The example is here:
Here it is:
We see a slightly different problem. We want to have a two-dimensional array, but we do not need the same length of all the rows. What we do, declare an array of indicators. The second row given below declares A as an array of pointers. Each indicator indicates a float. Here is some applicable code:
float linear a [30]; Float * A [6]; A [0] = Linear A; / * 5 - 0 = 5 elements in the row * / A [1] = Linear A +5; / * 11 - 5 = 6 elements in the row * / A [2] = Linear A +11; / * 15 - 11 = 4 elements in the row * / A [3] = Linear A +15; / * 21 - 15 = 6 element * / a [4] = Linear A +21; / * 25 - 21 = 4 element * / A [5] = Linear A + 25; / * 30 - 25 = 5 elements * / A [3] [2] = 3.66; / * 3.66 for Linear A [17]; * / A [3] [- 3] = 1.44; / * Linear A [12]; Negative indices are sometimes useful, but avoid using them as much as possible. * / My question is why why A [0] is an indicator for only five elements and not all linearA , Because the name of the array is an indicator for its first member. and A [1] = Linear A + 5; There are 6 elements in a row - for the same reason? Is A [1] considered to be an indicator for the 6th member of linearA ? Can anyone say that where's my fault?
Except for a few exceptions, the first element of an array name array in C is converted into an indicator . linearA is an array 30 float and in expression: a [0] = linear A; It is converted to an indicator on float . A An array of indicator 6 name . The element of a is the type indicator of the float . Then there is an indicator for a [0] a float and not an indicator for an array. and a [i] [j] is equal to c * (a [i] + j) a [i] [J] is a float (dereferencing an indicator for float a float ).
Comments
Post a Comment