2

right now c++ is giving me this error: error C2087 'color' missing subscript first time i get this and i dont know what to do >.< hope any1 can help me

struct Color{
    float r;
    float g;
    float b;
};
Color color[][];

and im using it here

for(int i=0;i<cubes;i++)
{
    color[i][0].r = fRand();color[i][0].g=fRand(.5);color[i][0].b=fRand();

...etc

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Makenshi
  • 993
  • 3
  • 15
  • 28

4 Answers4

5

You are trying to create an array without specifying its size. If the size is dynamic, you should use pointers instead. type x[][]; is always an error, regardless of type. You can initialize your array though, int x[] = {10,11}; // ok or int[][2]={{1,2},{1,2},{1,3}}; // also works

a1ex07
  • 36,826
  • 12
  • 90
  • 103
4

You should specify the size of your array:

Color color[HEIGHT][WIDTH];
Phong
  • 6,600
  • 4
  • 32
  • 61
2

Your definition of color lacks sizes for the subscripts. Therefore, the compiler cannot determine how much space to allocate for color.

sabauma
  • 4,243
  • 1
  • 23
  • 23
2

you're not specifying the size for the two-dimensional array as it seems. maybe that's causing the problem?