ARRAY vs POINTER ARRAY:

An array is a collection of elements of same datatype.
Whereas, pointer array is an array of collection of  pointers.
 
Example of ARRAY:
int A[] = {1,2,3,4,5};
here A is a Pointer  Variable .
Confused?  😉
Its a Pointer Variable that points to first element of array.
A  holds  &A[0] 
 
 
Example of POINTER ARRAY:
int *B[]={      };       //collection of  Pointers
here *B[] can be written as **B
Lets take an example of String dataType, 
String can be One Dimentional
or
can be   Two Dimentional array of characters, in which each row stores the strings in an array  😉
 
One Dimentional Array:
char *A[] = “This is jasleen”;
here A is a pointer variable that points to A[0]=This is jasleen
 
Two Dimentional Array:
char *C[]={“ENTNG”, “NST”, “AMAZI”, “FIRBE”};
 
Here,
C[0] = ENTNG
C[1] = NST
C[2] = AMAZI
C[3] = FIRBE
C  is a pointer variable that points to C[0] ,  C[0]  is again an array that stores the string ENTNG
 
             ______               _______________________________
 C[0]   |_2010_|             |__E_|__N__|__T__|_N__|_G__|_ _|
                                            2010  2011   2012    2013   2014  2015
                  
             ______               _______________________________
 C[1]   |_2016_|             |__E_|__N__|__T__|_N__|_G__|_ _|
                                            2016  2017   2018    2019   2020  2021
                     .
                     .
                     .  SO ON….
 
Now I can assume that had understood above well,   have you?
If  “NO” then revise again 🙂
Advertisements

About Jasleen Kaur

Hi, I am Jasleen kaur, a Computer Science Student.
This entry was posted in C++ and tagged , , , . Bookmark the permalink.

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