title: Segmentation fault passing an address specifically defined as a string
body: <p>Here's more code I whipped up since i was having trouble with my major program that I now fixed.</p>
  
  <p>I have a function which modifies a series of bytes. In this example, the function is supposed to fill up the first 9 bytes of the char array with the numbers 1 through 9 consecutively.</p>
  
  <p>Two tests are run. The first one is calling the function where the parameter is <code>(char*)&amp;myvar</code>. The second test only uses <code>myvar</code> as a parameter. I thought I always had to use an &amp; in front of a char array pointer when I want the string returned in the parameter portion of the function.</p>
  
  <p>Why does this program only work when I don't prepend <code>(char*)&amp;</code> to my char array variable?</p>
  
  <p>When I do apply it, I receive a segmentation fault.</p>
  
  <pre><code>#include "stdio.h"
  #include "stdlib.h"
  #include "string.h"
  
  int func(char* abc){
      char *p=abc;
      int n;
      for (n=1;n&lt;10;n++){
      *p=(unsigned char)(n+48);p++;
      }
      return 0;
  }
  
  int main(){
      char vars[1000]="234";
      char *myvar=vars;
  
      printf("Function test\n");
      int result=func((char*)&amp;myvar); //causes segfault
      printf("Function result %s\n",myvar); //segfault here
  
      printf("Function test again\n");
      int result2=func(myvar);        //works
      printf("Function result %s\n",myvar);
  
      printf("DONE\n");
      return 0;
  }
  </code></pre>