Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Is it possible to declare a pointer to an array of character pointers?
Here is the context:
char *colors[] = {"purple", "red", "blue", "green"};
char *names[] = {"Jim", "Bob", "David", "Tom"};void function myFunc (int param) {
int i;for (i =0; i < 4; i++)
if (condition)
myOutputFunc(colors[i]);
else
myOutputFunc(names[i]);
}Instead of the above code, what I'd really like is to declare at the beginning of myFunc a variable of type pointer to array of char *. Then, before the loop, assign this variable to point either to colors or to names. Then, in the loop, it would automatically move down the members of the appropriate array.
Is this possible? How would the declaration look? How would the reference to an individual member of the array work? How would the incrementation work?
Thank you in advance.

Woohoo! A char pointer pointer pointer!
void function myFunc (char ***param) {
int i;for (i =0; i < 4; i++)
myOutputFunc((*param)[i]);
}

![]() |
what's the best server si...
|
MIF files
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |