title: Global pointers between functions
body: <p>So I was trying to use a global pointer that I define in a function and I'm going to use in another function without passing as parameters. </p>
  
  <p>Here is my fun.c file</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int *step;
  int step_counter;
  
  int init(int num){
      step = &amp;num;
      step_counter = *step;
      return 0;
  
  }
  void reset_counter(){
      step_counter = *step;
      printf("%d ", step_counter);
  
  }
  </code></pre>
  
  <p>Here is the main.c file</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include "fun.c"
  
  int main()
  {
      init(3);
      reset_counter();
  return 0;
  }
  </code></pre>
  
  <p>I was expecting that the reset_counter function to print 3. But instead it prints out 0. I don't know what's the problem. I'm pretty new to C.</p>