how pointers are assigned to arrays
Answers
Answer:
You need to keep in mind that pointers can always be used to describe any array (single element of whole set of multiple elements).
Explanation:
Using a pointer in a programming language like “C” it is possible to define a single and multiple element. A single pointer can be used to describe 0th element and in the same way a pointer can also be used to describe a complete set of array. When speaking of pointers, they are best to describe multi-dimensional arrays.
Common syntax for setting up a pointer for describing an array is :-
Data_type (*var_name)[size of array].
You also need to keep in mind that a pointer that is used for describing a single or 0th element is entirely different as compared to using a pointer for describing a complete array. The basic point here is that a pointer always points towards a described array or whole array. So this also provides us with the base address of the described array.
When addressing multidimensional arrays or two dimensional array we can always make use of two subscripts for accessing each element. These can be in the form of a row and a column. You can also make use of the pointer notation to represent the elements within the 2 D array using common format *(*(arr+i) + j).
Here you need to keep in mind that both type of examples (arr + i) and the second one (arr + j) can be considered as standard format for array that are having a different set of base.