title: Pass character array by value and return a new character array from the function?
body: <p>I apologise if I'm completely misunderstanding C++ at the moment, so my question might be quite simple to solve. I'm trying to pass a character array into a function by value, create a new array of the same size and fill it with certain elements, and return that array from the function. This is the code I have so far:</p>
  
  <pre><code>char *breedMutation(char genome []){
      size_t genes = sizeof(genome);
      char * mutation = new char[genes];
      for (size_t a = 0 ;a &lt; genes; a++) {
          mutation[a] = 'b';
      }
      return mutation;
  }
  </code></pre>
  
  <p>The <code>for</code> loop is what updates the new array; right now, it's just dummy code, but hopefully the idea of the function is clear. When I call this function in <code>main</code>, however, I get an error of <code>initializer fails to determine size of ‘mutation’</code>. This is the code I have in main:</p>
  
  <pre><code>int main()
  {
      char target [] = "Das weisse leid"; //dummy message
      char mutation [] = breedMutation(target);
      return 0;
  }
  </code></pre>
  
  <p>I need to learn more about pointers and character arrays, which I realise, but I'm trying to learn by example as well.</p>
  
  <p>EDIT: This code, which I'm trying to modify for character arrays, is the basis for <code>breedMutation</code>. </p>
  
  <pre><code>int *f(size_t s){
      int *ret=new int[s];
      for (size_t a=0;a&lt;s;a++)
          ret[a]=a;
      return ret;
  }
  </code></pre>