Array of char *

Posted by user353060 on Stack Overflow See other posts from Stack Overflow or by user353060
Published on 2010-05-28T16:02:15Z Indexed on 2010/05/28 16:31 UTC
Read the original article Hit count: 223

Filed under:

Hello,

I am having problems with array pointers. I've looked through Google and my attempts are futile so far.

What I would like to do is, I have a char name[256]. I will be 10 of those. Hence, I would need to keep track of each of them by pointers.

Trying to create a pointer to them.

int main()
{
    char superman[256] = "superman";
    char batman[256] = "batman";
    char catman[256] = "catman";
    char *names[10];
    names[0] = superman;
    names[1] = batman;
    system("pause");
    return 0;
}

How do I actually traverse an array of pointers?

© Stack Overflow or respective owner

Related posts about c++