title: Beginner CUDA - Simple var increment not working
body: <p>I am working on a project with CUDA. To get the hang of it, I have the following code.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  __global__ void inc(int *foo) {
    ++(*foo);
  }
  
  int main() {
    int count = 0, *cuda_count;
    cudaMalloc((void**)&amp;cuda_count, sizeof(int));
    cudaMemcpy(cuda_count, &amp;count, sizeof(int), cudaMemcpyHostToDevice);
    cout &lt;&lt; "count: " &lt;&lt; count &lt;&lt; '\n';
    inc &lt;&lt;&lt; 100, 25 &gt;&gt;&gt; (&amp;count);
    cudaMemcpy(&amp;count, cuda_count, sizeof(int), cudaMemcpyDeviceToHost);
    cudaFree(cuda_count);
    cout &lt;&lt; "count: " &lt;&lt; count &lt;&lt; '\n';
    return 0;
  }
  </code></pre>
  
  <p>Output is</p>
  
  <pre><code>count: 0
  count: 0
  </code></pre>
  
  <p>What's the problem?</p>
  
  <p>Thanks in advance!</p>