Previous | Home | Next |
Array of pointers
Just like the array of the various types of the datatypes like integer, floats, we can also define an array of pointers. In the array of the pointers we can stores the addresses of the values as the elements, we can declare an array of pointer in the following way :
The above declaration tells us that arr is an array that contains the address of the 7 integers as its elements.
Following a little code snippet depicting the usage of the array of pointer :
#include <stdio.h> #include<conio.h> void main() { char *ptr1[3]; /* declared a array of character pointers */ ptr1[0]="hello ! "; /* first address corresponds to value hello */ ptr1[1]="how are"; /* second address corresponds to value how are */ ptr1[2]="you"; /* third address corresponds to value you */ printf("%s%s%s",ptr1[0], ptr1[1], ptr1[2]); getch(); }
Output : The output of the following program will be as follows :
hello! how are you
Previous | Home | Next |