title: Sizeof() on a C++ array works in one function, but not in the other
body: <p>I'm trying to learn more about arrays since I'm new to programming. So I was playing with different parts of code and was trying to learn about three things, <code>sizeof()</code>. How do I find the length of an array, and also how do I put arrays into functions (as a parameter)?</p>
  
  <p>My code is:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  void arrayprint(int inarray[])
  {
      for (int n_i = 0 ; n_i &lt; (sizeof(inarray) / sizeof(int)) ; n_i++)
      {
          cout &lt;&lt; inarray[n_i] &lt;&lt; endl;
      }
  }
  
  int main()
  {
      int n_array[5];
      for (int n_i = 0 ; n_i &lt; (sizeof(n_array) / sizeof(int)) ; n_i++ )
      {
          cin &gt;&gt; n_array[n_i];
      }
      arrayprint(n_array);
      return 0;
  }
  </code></pre>
  
  <p>It seems the <code>sizeof(inarray) / sizeof(int)</code> works in the main function, but not in the arrayprint function. In the array print function, it evaluates to 1, while in main it evaluates to 5. Why?</p>
  
  <p>So I guess what I want to know is how they are different? And why?</p>