title: Pointers in C for a rookie
body: <p>I am just starting to learn programming for a unit I am doing in my engineering course and I have come across pointers. I just wanted some reassurance that I actually understand the concept correctly in terms of using a pointer as an argument in a function. If I understand it correctly, you pass a pointer to an address of a variable you would like to be altered by a separate function called, even though it is a local variable within the scope of the calling function. Does that make sense? I have an example from my text book which I re-wrote. The only thing is they gave it in two incomplete parts and I put it together, filled in the blanks and added the final printf statement in the main function. I'll paste it here:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define READ_OK 0
  #define READ_ERROR 1
  
  int read_num(int lo, int hi, int *num);
  
  int main(int argc, char *argv[])
  {
      int lo = 0, hi = 0, *num, val;
      printf("Please enter a lower bound and an upper bound for your range,respectively\nLower: ");
      scanf("%d", &amp;lo);
      printf("Upper: ");
      scanf("%d", &amp;hi);
      num = &amp;val;
      if(read_num(lo,hi, &amp;val) != READ_OK)
      {
          printf("Read error, program abort\n");
          exit(EXIT_FAILURE);
      }   
      else
      {
          printf("You entered %d, press any key to continue: \n", val);
          getchar();
      }
      return 0;
  }
  
  int read_num(int lo, int hi, int *num)
  {
      int next;
      printf("Enter a number between %d and %d: ", lo, hi);
      while(scanf("%d", &amp;next)==1)
      {
          if (lo&lt;=next &amp;&amp; next&lt;=hi)
          {
              *num = next;
              return READ_OK;
          }
          printf("%d is not between %d and %d\nTry again: ", next, lo, hi);
      }
      return READ_ERROR;
  }
  </code></pre>
  
  <p>So is my understanding correct? "val" gets modified in read_num() by passing it's address in the form of pointer "*num", in which the the value for "next" is then written? 
  PS: is this syntax correct?
  PPS: What would this process specifically be called?</p>
  
  <p>Thanks a bunch for any help :) </p>