Reputation: 31
I have this array
int sequence[2][3][2][2][50][2] = {
{
{1},
{{
{2, 4},
{3, 5}
},
{255,0,0}
}
},
{
{2},
{{
{3, 4},
{2, 6}
},
{0,0,255}
}
}
};
Whenever I try to index the first multi dimensional array, using
int frame[2] = {sequence[1]}
I get this error "invalid conversion for 'int (*)[2][2][50][2]' to 'int' [-fpermissive]
What am I doing wrong?
Upvotes: 1
Views: 84
Reputation: 238461
Whenever I try to index the first multi dimensional array, using
int frame[2] = {sequence[1]}
Let's simplify the syntax you use:
int frame[2] = {/*list of ints*/}
This initializes a one dimensional array of 2 int
, using a brace-enclosed list of integers.
An element of your outermost multi-dimensional array with arity k
, is also a multi-dimensional array (with arity k-1
). It is not an int
.
So, there is nothing wrong with how you index the multi-dimensional array. What is wrong, is trying to initialize an array if int
with a multi-dimensional array as the first value.
How should I initialize it then?
It is impossible to answer because it is not clear which of the integer values within the multi-dimensional array you want to use to initialize.
Here is a syntactically correct way to initialize frame
:
int frame[2] = {sequence[0][0][0][0][0][0], sequence[0][0][0][0][0][1]};
It uses the values in the first subarray of the first subarray of the first subarray of the first subarray of the first subarray of the outermost array.
Upvotes: 1