title: Modifying a string being passed as argument of a function in C
body: <p>How can I <strong>modify</strong> the value of a string <strong>being passed as argument</strong> in a function?</p>
  
  <p>For example I have this function <code>foo</code> (that is supposed to change the value of <code>return_string</code> from <code>"old string"</code> to <code>"new string"</code>):</p>
  
  <pre><code>int foo(char *return_string) {
      char *tmp = "new string";
      return_string = tmp;
      return 0;
  }
  </code></pre>
  
  <p>But if I call it in the following way:</p>
  
  <pre><code>char *s = "old string";
  foo(s);
  printf("%s\n", s);
  </code></pre>
  
  <p>I still get <code>old string</code> as output. Why?</p>
  
  <p>I admit I have a little of confusion with pointers and strings in C.</p>