title: How to make an array to store char arrays of variable size?
body: <p>I need an array to store char arrays of variable size. I could use vectors or anything else, but unfortunately this is for a MPI project and I am forced to use an array so I can send it using <code>MPI::COMM_WORLD.Send(...)</code> function.</p>
  
  <p>My idea comes from <a href="https://stackoverflow.com/questions/5901476/sending-and-receiving-2d-array-over-mpi">this link</a>.</p>
  
  <p>This is a simplified example of the problem I have:</p>
  
  <pre><code>char* arrayStorage[3]; //I want to store 3 char arrays of variable size!
  int index = 0;
  
  char array_1[RANDOM_SIZE] = {.....};
  char array_2[RANDOM_SIZE] = {.....};
  char array_3[RANDOM_SIZE] = {.....};
  
  arraySorage[index] = array_1;
  index++;    
  arraySorage[index] = array_2;
  index++;
  arraySorage[index] = array_3;
  index++;
  </code></pre>
  
  <p>I have also seen people talking about <code>malloc</code> and stuff like that, but I don't know much about pointers.  I do <code>malloc</code>, I have to call <code>free</code> and I don't know where, so I am avoiding that for now.</p>
  
  <p>This code obviously doesn't work, <code>array_1</code>, <code>array_2</code>, <code>array_3</code> are all OK, but when I try to access them I get garbage. The problem seems to be inside the index variable. Maybe I shouldn't be doing index++, perhaps I should be doing index += RANDOM_SIZE, but that also fails.</p>
  
  <p>How can I store variable size char arrays in an array?</p>