Pointer vs Array

The pointer and array appears to be the same but there are many 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” stes 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 its unchangeable).
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s