title: Counting multidimensional array elements after function call
body: <p>I have a simple setup as follows (you can also test it here: <a href="http://cpp.sh/3yxqj" rel="nofollow">http://cpp.sh/3yxqj</a>):</p>
  
  <pre><code>// Example program
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  void a (const char c[][2])
  {
      std::cout &lt;&lt; "func c: " &lt;&lt; (sizeof(c)/sizeof(c[0])) &lt;&lt; std::endl;
  }
  
  int main()
  {
      const char c[][2] = {
        {1,2},
        {3,4},
        {5,6},
        {7,8},
        {9,10},
        {11,12},
       };
  
      std::cout &lt;&lt; "main c: " &lt;&lt; (sizeof(c)/sizeof(c[0])) &lt;&lt; std::endl;
  
      a(c);
  
      return 0;
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>main c: 6
  func c: 4
  </code></pre>
  
  <p>Where of course 6 is correct and 4 is not. I think I understand why this is happening. The array [][] degenerates (forgive this term) into a pointer (*)[] inside the function. I don't know how to solve this problem though. I need to be able to count rows in multidimensional array after passing it into a function. Can someone please help?</p>