Reputation: 17
I keep getting this error when declaring an int[2] array, but it looks fine to me.
error: too many initializers for 'int [2]'
int <array_name>[2] = { 0, 255, 255 };
^
am I doing someting wrong?
Upvotes: 0
Views: 565
Reputation: 64
You declared the size of array is 2 but gave it 3 elements, I think just change it to int <array_name>[3] will fix the problem
Upvotes: 2
Reputation: 361605
You declare the array to have two elements with [2]
, but you're trying to assign three numbers to it with { 0, 255, 255 }
. Something's gotta give.
Upvotes: 2