title: CUDA program giving garbage value
body: <p>I really do not understand why the output for the below code is not a and b.</p>
  
  <pre><code>#include&lt;cutil.h&gt;
  #include&lt;iostream&gt;
  __global__ void p(unsigned char **a){
  
  
  unsigned char temp[2];
  temp[0] = 'a';
  temp[1] = 'b';
  a[0] = temp;
  
  
  }
  
  void main(){
  
      unsigned char **a ;
      cudaMalloc((void**)&amp;a, sizeof(unsigned char*));
      p&lt;&lt;&lt;1,1&gt;&gt;&gt;(a);
      unsigned char **c;
      unsigned char b[2];
      cudaMemcpy(c, a, sizeof(unsigned char *), cudaMemcpyDeviceToHost);
      cudaMemcpy(b, c[0], 2*sizeof(unsigned char), cudaMemcpyDeviceToHost);
      for( int i=0 ; i &lt; 2; i++){
          printf("%c\n", b[i]);
      }
  
  
      getchar();
  
  
  }
  </code></pre>
  
  <p>what is wrong with my logic?</p>