title: Updating global variable from a thread
body: <p>What I have is a simple code that starts a thread for the purpose of collecting user input and updating the result accordingly: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;pthread.h&gt;
  
  int x;
  
  void *inc_x(void *x_void_ptr)
      {
      int *x_ptr = (int *)x_void_ptr;
  
      while(1)
          scanf("%d", &amp;x_ptr);
  
      return NULL;
      }
  
  int main()
      {
      int y = 0;
  
      pthread_t thread_ID;
      pthread_create(&amp;thread_ID, NULL, &amp;inc_x, &amp;x) ;
  
      while(1)
          {
          printf("x: %d, y: %d\n", x, y);
          sleep(1);
          }
  
      return 0;
      }
  </code></pre>
  
  <p>The problem is that X never get's updated, why ?</p>