As you know that we can pass one value at a time through one argument of any function. What, if we want to pass more than one value through one argument of a function, here is place where pointers comes.
pointers stores addresses, and we pass address to a function we can access it's value. So the general definition to pass a pointer to a function is:
return_type Function_name(date_type_of_the_pointer);
For Example:
main()
{
int a=23,*add_of_a;
add_of_a=&a;
show_value(add_of_a);
}
void show_value(int *add)
{
printf("\nThe Value of a = %d",add);
}
Now you want to pass many pointers then you can define array of pointers
as follows:
Data_type *Arr_of_pointers_name[SIZE];
Now as you have passed the address of single value, here also you have to pass only one value, i.e. the address of the first element of the array of pointers.
For Example:
main()
{
char STRING[]="BOSS";
char *add_of_first_element_of_arr;
add_of_first_element_of_arr=&STRING[0];
show_string(add_of_first_element_of_arr);
}
void show_string(char *add)
{
int i=0;
while(add[i]!='\0')
{
printf("%c",add[i]);
i++;
}
}
Here in the show_string() func we have passed the address of STRING[0],And we collected it in add. By add variable now we can access the whole string just by incrementing the value if i. Or we can print the whole string just by puting this printf() statement printf("%s",add) in the show_string() func.