Pointer vs Array

The pointer and array may naively appear to be the same but there is some major difference between them.

  • In array, the sizeof operator returns the total memory stored by the array.
    In pointer, the sizeof operator returns the memory of pointer variable alone.
  • In array, the & operator will provide the address of the first element.
    In pointer, the & operator will provide the address of the pointer variable.
  • Char array[]=”abc” sets the first four elements in array to ‘a’,’b’,’c’ and ”.
    char *pointer=”abc” sets the pointer to the address of the “abc” string(Which may be stored in read-only memory and so it’s unchangeable).

Leave a comment