Reputation: 23
I am trying to access the first element inside the array 'levels'.
unsigned char Level1[70] =
{
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x01,0x01,0x01,0x01,0x01,0x03,0x07,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x03,0x02,0x02,0x01,
0x01,0x01,0x0b,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x08,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x0f,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02
};
unsigned char (*levels)[1] = {&Level1};
I have tried things like:
unsigned char curr_level[70] = levels[0];
but they have not worked.
Thank you!
Upvotes: 1
Views: 115
Reputation: 741
WARNING: this answer may be INCORRECT See comments for details.
According to your declaration,
unsigned char (*levels)[1] = {&Level1};
levels
is an array of char pointers, and therefore levels[0]
is a char pointer.
So depending on what you want to do, you may try one of the followings:
unsigned char *curr_level=levels[0];
or
unsigned char *curr_level;
curr_level=malloc(sizeof(Level1)); /* Don't forget to call free() on it later */
memcpy(curr_level,levels[0],sizeof(Level1));
Upvotes: 1