title: Passing a struct to a thread as a value parameter
body: <p>I want to create more than one thread with a vector of threads and I'm trying to pass a struct with values that are changing with every call. The problem is I don't want to pass the struct as a memory location with &amp;, because every thread receives a different value of the struct.  I want to pass the struct as a value parameter. When I try, the gcc compiler throws an error: Violation segment ( `core 'generated). Here is part of my code:</p>
  
  <pre><code>//the struct
  struct intervalos{
    int from;
    int to;
    int number;
  };
  
  
  // the calls
  for (int i = 0; i&lt;=num ; i++){
      struct intervalos *inter;
  
      /*re asign the values of the struct...*/
  
      pthread_create( &amp;vector[i], NULL, fun, inter);
  }
  
  
  //function of threads
  void* fun(void* data) {
      struct intervalos *inter = data ;
      /* do something else */
  }
  </code></pre>