title: C initializing array of arrays
body: <p>I have this problem. I need to have an array of float arrays to store before i run some functions. How can i accomplish that, since i cannot initialize an array withut a non constant? Should i make a function that will create that array with malloc then return in and assign to a pointer?</p>
  
  <pre><code>typedef struct
  {
      float RGBA[4];
  } graphColors;
  </code></pre>
  
  <p>I need to have an array of grapColors. I'm sorry for my lack of knowledge, im a Java programmer and need to work with C now.</p>
  
  <p>EDIT:</p>
  
  <pre><code>graphColors *initializeGraphColors(){
      graphColors *gp;
      int i;
      float HI = 1.0f;
      float LO = 0.0f;
  
      float temp[] = {1.0f, 1.0f, 1.0f, 0.0f};
      gp = (graphColors *) malloc(nrOfLines * sizeof(graphColors));
  
      for(i = 0;i &lt; nrOfLines; i++){
          gp[i].RGBA[0] = LO + (float)rand()/((float)RAND_MAX/(HI-LO));
          gp[i].RGBA[1] = LO + (float)rand()/((float)RAND_MAX/(HI-LO));
          gp[i].RGBA[2] = LO + (float)rand()/((float)RAND_MAX/(HI-LO));
          gp[i].RGBA[3] = 0.0f;
      }
      return gp;
  }
  </code></pre>
  
  <p>Then in my class:</p>
  
  <pre><code>graphColors *gc;
  gc = initializeGraphColors();
  </code></pre>
  
  <p>Getting this error:</p>
  
  <pre><code>error C2040: 'gc' : 'graphColors *' differs in levels of indirection from 'graphColors'
  </code></pre>