title: Changing a variable in a thread in C
body: <p>I know this is very basic but I'm having trouble getting to it, and english is not my native language so sorry for any typos. </p>
  
  <p>I have this program that must use 2 threads to calculate the sum of square roots of the first 999999 numbers. One of the threads must sum up the pairs and the other the odds. My problem comes when changing the variables of each sum in the threads, I get always 2 errors and can't even compile. I'm quite new with pointers so I'm guessing the problem is there. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;pthread.h&gt;
  #include &lt;math.h&gt;
  
  
  void *calc_pairs(void *sum){
  
      int i;
  
      for(i=0;i&lt;=999999;i=i+2){
  
              *sum += sqrt(i);
          }
  
      pthread_exit(NULL);
  
  }
  
  void *calc_odds(void *sum1){
  
      int a;
  
      for(a=1;a&lt;999999;a=a+2){
                  *sum1 += sqrt(a);
              }
  
      pthread_exit(NULL);
  
  }
  
  
  int main(int argc, char** argv) {
  
      pthread_t threads[2];
  
      double sum=0;
      double sum1=0;
      double sum_total;
  
      pthread_create(&amp;threads[0],NULL, calc_pairs,(void *)&amp;sum);
      pthread_create(&amp;threads[1],NULL, calc_odds,(void *)&amp;sum1);
  
  
  
      pthread_join(0);
      pthread_join(1);
  
  
      sum_total = sum1+sum;
  
      printf("The sum calculated on the threads is %f", sum_total);
  
  
      return (EXIT_SUCCESS);
  }
  </code></pre>
  
  <p>The errors I get are:</p>
  
  <p>Invalid use of void expression. Warning: Dereferending 'void *' pointer [enabled by default]</p>
  
  <p>Both errors in the lines where I calculate the squares.</p>