title: MPI_Send/Recv C++ std::string Segmentation Fault
body: <p>I've read a bunch of pages on here and posted a previous similar question to no avail and I just can not seem to find a workable solution.</p>
  
  <p>This is a uni assignment with provided code to start off which is horrible but we have to use it :/ I'm not asking for a solution to the whole thing, just MPI_Send and Recv as I'm stumped.</p>
  
  <p>Master:</p>
  
  <pre><code>string parent; //Is initialised to a random sequence of characters before I try the send
  int parentSize = parent.size()+1;
  
  for (int i = 1; i &lt; processes; i++)//Send current parent to slaves
  {
      MPI_Send(&amp;parentSize, sizeof(int), MPI_INT, i, MSIZE, MPI_COMM_WORLD); //This works fine
      MPI_Send(&amp;parent, parent.size(), MPI_BYTE, i, MSEND, MPI_COMM_WORLD);
  }
  </code></pre>
  
  <p>Slaves:</p>
  
  <pre><code>int parentSize;
  
  MPI_Recv(&amp;parentSize, sizeof(int), MPI_INT, 0, MSIZE, MPI_COMM_WORLD, &amp;status); //Works fine
  MPI_Recv(&amp;parent, parentSize, MPI_BYTE, 0, MSEND, MPI_COMM_WORLD, &amp;status); //Gives a segfault when I try to cout parent
  </code></pre>
  
  <p>Am I allocating an incorrect amount of memory? I believe size() will return the number of chars in the string (28) and + 1 for null terminator?</p>