title: manage array of memory directions
body: <p>I have several variables inside a <em>struct</em>.</p>
  
  <pre><code>struct my_struct{
      float variable_2_x[2],variable_2_y[2],variable_2_z[2];
      float coef_2_xyz[3];    
  
      float variable_3_x[3],variable_3_y[3],variable_3_z[3];
      float coef_3_xyz[3];
  
      float variable_4_x[4],variable_4_y[4],variable_4_z[4];
      float coef_4_xyz[3];
  };
  </code></pre>
  
  <p>This struct its going to contain Lagrange polynomial (en.wikipedia.org/wiki/Lagrange_polynomial) coefficients, for several polynomial lenght: 2, 3, 4. The value of this coefficients its easy to calculate but the problem is, that i have to repeat the same code to create every single polynomial. for example</p>
  
  <pre><code>// T_space is a cube with {[-1:1][-1:1][-1:1]} dimension, 
  // its call transformed space.
  // distance is the distance between two points of T_space
  // point_1 its the point where the function has value 1
  p = 2; 
  step = distance / p;
  
  polinoms.coef_2_xyz[0] = 1.0:
  polinoms.coef_2_xyz[1] = 1.0:
  polinoms.coef_2_xyz[2] = 1.0:
  for( i = 0; i &lt; p ; ++i) 
  {
      polinoms.pol_2_x[i] = (T_space.xi[point_1] + step) + (i * step);
      polinoms.pol_2_y[i] = (T_space.eta[point_1] + step) + (i * step);
      polinoms.pol_2_z[i] = (T_space.sigma[point_1] + step) + (i * step);
  
  
      polinoms.coef_2_xyz[0]*= (T_space.eta[point_1] - polinoms.pol_2_x[i]);
      polinoms.coef_2_xyz[1]*= (T_space.eta[point_1] - polinoms.pol_2_y[i]);
      polinoms.coef_2_xyz[2]*= (T_space.eta[point_1] - polinoms.pol_2_z[i]);
  
  }
  </code></pre>
  
  <p>As i don't want to repeat the same loop several times in the code. And what is more important next step in the code i need to integrate the product of the gradient of the polynomial, to every point in the cube.</p>
  
  <p>It will very useful beening able to call every array of the struct independently. 
  As i know that, variables can't be dynamically called on runtime. I think of making an array which contains the memory directions of the <em>struct</em>. something like this.</p>
  
  <pre><code>// declare variable to store memory directions
  float mem_array[12];
  
  // some code
  
  mem_array[0] = &amp;variable_2_x;
  mem_array[1] = &amp;variable_2_y;
  mem_array[2] = &amp;variable_2_z;
  mem_array[3] = &amp;coef_2_xyz;
  mem_array[4] = &amp;variable_3_x;
  
  mem_array[11] = &amp;variable_4_z;
  mem_array[12] = &amp;coef_4_xyz;
  
  // work calling mem_array.
  </code></pre>
  
  <p>But i don't know if this is possible or if it will work. If you think this is not the proper way to face the problem, i'm open to advice. Because i'm really stuck with this.</p>
  
  <p>I have edited the question to be more clear, hope it will help.</p>