title: How to find the size of an int[]?
body: <p>I have</p>
  
  <pre><code>int list[] = {1, 2, 3};
  </code></pre>
  
  <p>How to I get the size of <code>list</code>?</p>
  
  <p>I know that for a char array, we can use <code>strlen(array)</code> to find the size, or check with <code>'\0'</code> at the end of the array. </p>
  
  <hr>
  
  <p>I tried <code>sizeof(array) / sizeof(array[0])</code> as some answers said, but it only works in main? For example:</p>
  
  <pre><code>int size(int arr1[]){
      return sizeof(arr1) / sizeof(arr1[0]);
  }
  
  int main() {
      int list[] = {1, 2, 3};
  
      int size1 = sizeof(list) / sizeof(list[0]); // ok
      int size2 = size(list_1); // no
      // size1 and size2 are not the same
  }
  </code></pre>
  
  <p>Why?</p>