• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
July 07, 2022 |38.2K Views
Pointer to an Array PART - 1
  Share  1 Like
Description
Discussion

In this program, we have a pointer ptr that points to the 0th element of the array. Similarly, we can also declare a pointer that can point to whole array instead of only one element of the array. This pointer is useful when talking about multidimensional arrays. 
Syntax:  

data_type (*var_name)[size_of_array];
Example:

int (*ptr)[10];

Here ptr is pointer that can point to an array of 10 integers. Since subscript have higher precedence than indirection, it is necessary to enclose the indirection operator and pointer name inside parentheses. 

Here the type of ptr is ‘pointer to an array of 10 integers’. 
Note : The pointer that points to the 0th element of array and the pointer that points to the whole array are totally different. The following program shows this: 


Pointer to an Array PART - 1  : https://www.geeksforgeeks.org/pointer-array-array-pointer/

Read More