Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Multidimensional C Arrays

I have four arrays that contains some values. Another array should contain all these four arrays like shown in the code:

static const long ONE_COLOR[2] = { RGB_BLACK, RGB_WHITE };
static const long TWO_COLOR[4] = { RGB_WHITE, RGB_RED, RGB_GREEN, RGB_BLUE };
static const long THREE_COLOR[8] = { RGB_BLACK, RGB_RED, RGB_GREEN, RGB_BLUE,
    RGB_CYAN, RGB_YELLOW, RGB_MAGENTA, RGB_WHITE };
static const long FOUR_COLOR[16] = { RGB_WHITE, RGB_RED, RGB_GREEN, RGB_BLUE,
    RGB_CYAN, RGB_YELLOW, RGB_MAGENTA, RGB_DARK_RED, RGB_DARK_GREEN,
    RGB_DARK_BLUE, RGB_LIGHT_BLUE, RGB_LIGHT_GREEN, RGB_ORANGE, RGB_LIME,
    RGB_PINK, RGB_LILA };

//this array should contain all other arrays
static const long COLOR_ARRAY = {ONE_COLOR,TWO_COLOR, THREE_COLOR,
    FOUR_COLOR };

My problem is to access the values in the array. I thought I can receive the value of RGB_BLACK with COLOR_ARRAY[0][0]. I tried it with some pointer constructions, but it doesn't work neither :(

Answer*

Cancel
1
  • This is hardly helpful, and violates the original license on the code you posted. Commented May 9, 2013 at 23:53