title: Can someone explain this C++ program.The result is weird :(
body: <p>This is a problem in a test. I expect the result is 1:1 but run it and get the answer 1:5, although I've debug it in Visual C++ 2013 and see the value of the adress which 'a' point to is 1 (the last '1' in 1:1)</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int fact(int *a)
  {
      if (*a &lt;= 1)
      {
          return a[0];
      }
      else
      {
          return a[0] * fact(&amp;(--*a));
      }
  }
  int main()
  {
      int *a = new int;
      *a = 5;
      cout &lt;&lt; fact(a) &lt;&lt; ":" &lt;&lt; *a;
      return 0;
  }
  </code></pre>