title: Number of elements of the inner arrays of a multidimentional array in C
body: <p>I am new to C and by reading online I understand that with sizeof() I can have the memory that is allocated to it in bytes, and if I divide it by an element inside it or the data type, I can have the number of elements of an array.</p>
  
  <p>I am trying to use this logic with a 2d multidimensional array and I'm having problems with the inner arrays.</p>
  
  <p>Here is a code sample:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  #define ARRAYLEN(arr) (sizeof(arr) / sizeof(arr[0]))
  
  int main(void) {
      int input[][20] = {
          {90, 1349, 430, 198, 677, 1869, 1692, 1098, 761, 677, 1004 ,0},
          {163, 642 ,2445, 1032, 2738 ,1591 ,3950 ,1600 ,651, 0},
          {1730 ,3067 ,1956, 723 ,1307 ,417 ,2838 ,1486 ,3114 ,3698 ,1881 ,0},
          {2337, 5131 ,1527 ,5042 ,953, 0},
          {80, 389, 413 ,209 ,219, 100 ,191, 419, 181 ,473 ,271 ,0},
          {22 ,3900 ,4057, 439 ,2642, 1447 ,3553, 2244, 3328, 3924, 1486, 400, 2394 ,0},
          {2870, 621 ,3779, 3508, 3729, 2985, 1083, 1384, 3782 ,2606, 637, 0},
          {1400, 108 ,472 ,1411, 10, 453, 1631, 1331, 0},
          {808 ,1584, 2545, 2294, 1983, 842 ,447, 807 ,3711, 1067, 490, 0},
          {435 ,14 ,261, 395, 340, 340, 25, 114, 178 ,52 ,232 ,19, 54, 0},
          {6181 ,2026, 4061, 7796 ,5192 ,958, 4190, 965 ,2642, 5082, 2579, 1872 ,0},
          {2030, 106, 579, 36, 1147 ,111 ,1393 ,459, 209, 1847, 1171, 415, 725, 1245, 0}
      };
  
      printf("%d", ARRAYLEN(input));
      printf(" ");
      printf("%d", ARRAYLEN(input[0]));
  
      printf(" ");
      printf("%d", sizeof(input[0]) / sizeof(int));
  
      return 0;
  }
  </code></pre>
  
  <p>The first <code>printf()</code> returns <code>12</code> which is right, but the second <code>printf()</code> (and third) return <code>20</code> which is the memory I've allocated to it but not the number of elements that each one has, which is what I am looking for in order to use on a for loop.</p>
  
  <p>Can someone explain how can I do this? Or what I am doing wrong?</p>
  
  <p>I can't find an answer/explanation anywhere.</p>
  
  <p>Thanks in advance</p>