Pointers and Array

POINTERS AND ARRAY

function is a block of statements that performs a specific task. The pointer reduces the code and improves performance. We can return multiple values from a function using the pointer. It makes you able to access any memory location in the computer's memory.

The pointer in c language can be declared using * (asterisk symbol). It is also known as indirection pointer used to dereference a pointer.

POINTER TO ARRAY

We declare pointer in this way
Example:- int arr[10];
                int *p[10]=&arr; // variable p of type pointer is pointing to the address of an integer array arr. 

This derives two facts:-

1. Array elements are always stored in contiguous memory locations. 

2. A pointer when incremented is always points immediately to the next location of its types.

Since a pointer variable always contains an address, an array of pointers would be nothing but a collection of addresses. 
The addresses present in the array of pointers could be addresses of isolated variables or addresses of array elements or any other addresses.  

Post a Comment

0 Comments