What is Pointer

What is Pointer?

Pointer is a special variable that represent the address/location of the data item. It provides an alternative way to access the value of a variable.
Pointer is used only store/hold memory address of any variable.

There are some reason to why Pointer used in programs:

  1. A pointer able to access a variable that is defined outside the function.
  2. Pointer are more efficient in handle the data table.
  3. Pointers reduce the length and complexity of the program.
  4. Pointer increase the speed of program execution.
  5. The use of the Pointer array to character string, result in saving of data storage space in memory.
Pointer Notation

Let's declare a integer variable n which value is 10:

int n = 10 ;

What is this meaning? The above declaration tells the C compiler that:

  1. Reserve space in memory to hold the integer value i.e. 65220
  2. Associate the name with this memory location i.e. n
  3. Store the value at location i.e. 10 
and the memory map of above declaration as:

       n --------> location name
     10 --------> value at location
65220 --------> location/address number

The important point to note in memory map that n's address in memory is a number ( in next chapter we see how it is important? ).


Related programs:


  1. Concept of Pointer
  2. Pointer basic example
  3. Pointer extend example

Comments