title: How to pass string by reference in Arduino C++
body: <p>I am new to Arduino, and haven't done any C++ for almost a decade. So here my really basic question:</p>
  
  <p>I want to make a function that can return two strings, for that i was thinking in passing the strings by reference. Something like this:</p>
  
  <pre><code>void return_array_byref((char[]) &amp; device, (char[]) &amp; command) 
  {
      device = malloc(8 * sizeof(char));
      device[0] = 'C';
      device[1] = '\n';
  
      command= malloc(8 * sizeof(char));
      command[0] = 'C';
      command[1] = '\n';
  }
  
  void loop() {
      char * device;
      char * command;
      return_array_byref(device, command);
  
      ...
  }
  </code></pre>
  
  <p>I have tried using <code>char **</code>, <code>char[] &amp;</code>, <code>char * &amp;</code> but nothing seems to work. With the code above I am getting this:</p>
  
  <pre><code>arduino:6:25: error: variable or field 'return_array_byref' declared void
  
   void  return_array_byref((char[]) &amp; device)
  
                           ^
  </code></pre>
  
  <p>What is the right way of doing this in C++?</p>
  
  <p><strong><em>[EDIT][SOLUTION]</em></strong></p>
  
  <p>This is the code I was looking for. I arrived to this solution based on the the answer provided bellow, so the credit goes to @Doncho :)</p>
  
  <pre><code>void return_array_byref(char * * device) 
  {
  
    *device = (char*) malloc(sizeof(char) * 8); // allocate the size of the pointer array
  
     (*device)[0] = 'A';
     (*device)[1] = 'B';
     (*device)[2] = 'C';
     (*device)[3] = '\n'; // this is just a new line, does not end the string
     (*device)[4] = '\0'; // null terminator is important!
  }
  
  void main() 
  {
    char * string;
    return_array_byref(&amp;string);
  
    cout &lt;&lt; string &lt;&lt; endl; 
  
    free(string);
  }
  </code></pre>