ARRAY OF POINTERS:
Array of pointers are used to define
more than one pointer variable of the same data type. The general format of declaring array of
pointers is:
Syntax: datatype *ptrvariable[size];
Where,
Datatype specifies type of the data
that can be pointed by each pointer variable.
Ptrvariable is name of the pointer
variable that follows same rules as a valid identifier.
Size represents maximum number of
elements.
Example: int *ptr[10];
/* EXAMPLE PROGAM 1 FOR ARRAY OF POINTERS */
main()
{
int i,*p[5],a,b,c;
clrscr();
a=10;
b=20;
c=30;
p[0]=&a;
p[1]=&b;
p[2]=&c;
printf("\nElements Are:");
for(i=0;i<3;i++)
printf("%5d",*p[i]);
}
No comments:
Post a Comment