C - Error while passing structure to threads
<p>Here I have a <code>struct</code></p>

<pre><code>struct dotData{
    long x;
    long y;
};
</code></pre>

<p>Which I try to pass to multiple <code>threads</code></p>

<pre><code>void *find_z(void *thisdot)
{
    long z;
    struct dotData *data;
    *data = *((struct dotData*)(thisdot));
    z = data.x + data.y;
    printf("Here's our dot! %ld * %ld = %ld \n", data.x, data.y, z);
    pthread_exit(NULL);
}
</code></pre>

<p>From <code>main()</code> where I create a struct <code>thisdot</code>, which is passed as an argument to <code>find_z</code> every time its elements <code>x</code> and <code>y</code> are changed</p>

<pre><code>int main()
{
.
.
.
    struct dotData thisdot;

    int NUM_THREADS;
    NUM_THREADS = N*M;
    pthread_t threads[NUM_THREADS];
    int i, j;

    for(i = 0; i &lt; M; i++){
        for (j = 0; j &lt; N; j++) {
            thisdot.x = x_dotBegin + x_interval*j;
            thisdot.y = y_dotBegin + y_interval*i;
            pthread_create(&amp;threads[NUM_THREADS], NULL, find_z, &amp;thisdot);
        }
    }
    pthread_exit(NULL);
}
</code></pre>

<p>However, during compilation I get an error in <code>z = data.x + data.y;</code></p>

<pre><code>error: request for member ‘x’ in something not a structure or union|
error: request for member ‘y’ in something not a structure or union|
</code></pre>

<p>How do I correctly pass this struct to threads?</p>