title: Understanding pointers used for out-parameters in C/C++
body: <p><a href="https://stackoverflow.com/questions/5660527/how-do-i-return-a-char-array-from-a-function">How do I return a char array from a function?</a></p>
  
  <p>has the following code in the answers:</p>
  
  <pre><code>void testfunc(char* outStr){
    char str[10];
    for(int i=0; i &lt; 10; ++i){
      outStr[i] = str[i];
    }
  }
  
  int main(){
    char myStr[10];
    testfunc(myStr);
    // myStr is now filled
  }
  </code></pre>
  
  <p>Since I will be using an Arduino where memory is precious I dont want a "temporary variable" for storing some string and then copying it over. I also don't want the function to return anything. I want to use the idea above and do something like:</p>
  
  <pre><code> void testfunc(char* outStr){
       outStr="Hi there.";
    }
  
  int main(){
    char myStr[10];
    testfunc(myStr);
  
  }
  </code></pre>
  
  <p>However, in this case myStr is empty!</p>
  
  <p>Why doesn't this work? How do I fix it?</p>
  
  <p>(I'm relatively new to C, and do have a basic understanding of pointers)</p>
  
  <p>Thanks.</p>