title: string argument in thread function
body: <p>I'm having problems passing a string to a thread function using pthread_create
  I get strange charactes when i run the progam
  here is the code</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/wait.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;time.h&gt;
  #include &lt;string.h&gt;
  #include &lt;sys/stat.h&gt;
  
  #define NTHREADS 3
  
  
  
  void *myFun(void *ptr){
       char * string;
       string = (char *) ptr;
       printf("string: %s\n", string);
  
      return NULL;
  }
  
  int main(int argc, char *argv[]){
      pthread_t threads[NTHREADS];
      char* thread_args[NTHREADS];
      int i;
      char* string;
      /* spawn threads */
      for (i=0; i&lt;NTHREADS; ++i){
          string = "file1.txt";
          thread_args[i] = string;
          if(pthread_create(&amp;threads[i], NULL, myFun, (void *) &amp;thread_args[i]) != 0){ 
              printf("Error creating thread\n");
              exit(1);
          }
      }
    /* Wait for threads to finish */
      for (i=0; i&lt;NTHREADS; ++i) {
          pthread_join(threads[i], NULL);
      }
      return 0;
  }
  </code></pre>
  
  <p>I can pass a int without problems doing a cast to int in the same way i did in the code, but with char it is not working.</p>