title: C: Passing Strings by reference?
body: <p>I wrote the following code in order to understand setjmp and longjmp functions but I think the issue is unrelated to those functions. I am expecting the output to be:</p>
  
  <pre><code>function1
  function2
  function2
  </code></pre>
  
  <p>but I keep getting:</p>
  
  <pre><code>function1
  function2
  function1
  </code></pre>
  
  <p>as the out put. Code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;setjmp.h&gt;
  #include &lt;stdlib.h&gt;
  
  void f1(char * a);
  void f2(char * a);
  
  jmp_buf buf1;
  
  int main(int argc, char *argv[])
  {
     char * w;
     f1( w);
     return 0;
  }
  
  void f1(char * a)
  {
     a = "funtion 1";
     printf("%s\n",a);
  
     int i = setjmp( buf1 );
     if( i == 0 )
        f2( a );
  
     printf("%s\n", a);
  
  }
  
  void f2(char * a)
  {
     a = "function 2";
     printf("%s\n",a);
     longjmp( buf1 , 2 );
  }
  </code></pre>
  
  <p>What am I doing wrong here ? Thanks for any help.</p>