title: What's the difference between global and local pointers?
body: <p>I have a small code something like this:</p>
  
  <pre><code> #include &lt;stdio.h&gt;
  
      int *ptr1;
      int *ptr2;
  
  
    void some_function(void)
      {
  
      int B = 5;
      ptr2 = &amp;B;
      }
  
    main (){
      int C, D;
      int A =10;
      int *ptr3;
      ptr1= &amp;A;
  
      ptr3=ptr2;
  
      some_function();
  
      C = *ptr1 + *ptr2;
  
      printf("Sum of the numbers C= %d\n",C);
  
      some_function();
      D = *ptr1 + *ptr3;
  
      printf("Sum of the numbers D= %d\n",D);
  
    }
  </code></pre>
  
  <p>Why dont I get the result for D but get the result for C? I get the result for the print statement S<code>um of the numbers C=15</code> but nothing for the last print statement for D. What is the difference between local and global pointers ( I mean both ptr1 and ptr2 are defined global and ptr3 is define local)? Is the pointer assignment <code>ptr3=ptr2</code> valid? are there any significant difference with pointer to local variable Vs. pointer to global variable ?</p>