title: function as parameter vs function pointer as parameter
body: <p>While listening through Stanford's <a href="http://see.stanford.edu/see/courseinfo.aspx?coll=11f4f422-5670-4b4c-889c-008262e09e4e" rel="noreferrer">Programming Abstractions</a> course, I come across some piece of code that looks like the following.</p>
  
  <pre><code>void plot(double start, double end, double (fn)(double)) {
      double i;
      for (i = start; i &lt;= end; i += 1)
          printf("fn(%f) = %f\n", i, fn(i));
  }
  
  double plus1(double x) {
      return x + 1;
  }
  
  int main(void) {
      plot(1, 10, plus1);
      return 0;
  }
  </code></pre>
  
  <p>I compiled the code on my system using GCC, then G++; they both run perfectly.</p>
  
  <p>I know that passing an <code>int i = 2</code> into a function such as <code>void func1(int a)</code> will make a new copy of that <code>i</code> for that function while passing <code>&amp;i</code> to <code>void func2(int *a)</code> will only give the function <code>func2</code> the address of <code>i</code>.</p>
  
  <p>So can anyone explain to me what is the mechanism for passing <code>fn</code> to <code>plot</code> and how it differs from passing a function pointer as parameter?</p>