title: Copying struct data from host to device on CUDA using cudaMemcpy
body: <p>I am facing a problem in copying struct data from host to device in the CUDA architecture.<br>
  Following is the code snippet.</p>
  
  <pre><code>struct point  
  {  
       double x,y;  
  };
  
  int main()  
  {  
     point * a = (point*)malloc(sizeof(point));  
     a-&gt;x=10.0;   
     a-&gt;y=10.0;    
     point * d_a;  
     cudaMalloc((void**)d_a,sizeof(point));  
     cudaMemcpy((void**)d_a,a,sizeof(point),cudaMemcpyHostToDevice);  
     dim3 dimblock(16,16);  
     dim3 dimgrid(1,1);  
  
     MyFunc&lt;&lt;&lt;dimgrid,dimblock&gt;&gt;&gt;(d_a);  
     cudaMemcpy((void**)a,d_a,sizeof(point),cudaMemcpyDeviceToHost);    
     printf("%lf %lf\n",a-&gt;x,a-&gt;y);
  }  
  
  __global__ void MyFunc(point* d_a)  
  {  
       if(threadIdx.x == 0 &amp;&amp; threadIdx.y == 0)
       {  
          d_a-&gt;x=100.0;  
          d_a-&gt;y = 100.0;    
       }
  }  
  </code></pre>
  
  <p>The x and y fields of point a should have been changed to 100. Instead, it is still 10 as initialized. What is happening here? Please help.</p>