Computing.Net > Forums > Programming > Pointer to array of character pointers?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Pointer to array of character pointers?

Reply to Message Icon

Name: Yisrael Harris
Date: August 8, 2002 at 11:54:23 Pacific
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Jim
Date: August 8, 2002 at 13:03:00 Pacific
Reply:

Woohoo! A char pointer pointer pointer!

void function myFunc (char ***param) {
    int i;

    for (i =0; i < 4; i++)
        myOutputFunc((*param)[i]);
}


0
Reply to Message Icon

Related Posts

See More


what's the best server si... MIF files



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Pointer to array of character pointers?

C arrays of strings from a file www.computing.net/answers/programming/c-arrays-of-strings-from-a-file/14025.html

Array of pointers to Structures www.computing.net/answers/programming/array-of-pointers-to-structures/1579.html

pointers to arrays www.computing.net/answers/programming/pointers-to-arrays/9741.html