title: Print 2d array by calling a function print_array with argument the 2d array
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  #define length 100
  
  void print_array();
  
  int main()
  {
      int m,n,i,j;
      int A[length][length];
      printf("Give dimensions of array (up to 100x100):\ni:\n");
      scanf("%d",&amp;i);
      printf("j:\n");
      scanf("%d",&amp;j);
      srand(time(NULL));
      for (m=0;m&lt;i;m++)
      {
          for (n=0;n&lt;j;n++)
          {
              A[m][n]=rand()%45+1;
              printf("A[%d,%d]=%d\n",m,n,A[m][n]);
          }
      }
      print_array(i,j,A);
      return 0;
  }
  
  void print_array(int i,int j,int A[][j])
  {
      printf("\n");
      int m,n;
      for (m=0;m&lt;i;m++)
          {
              for (n=0;n&lt;j;n++)
              {
                  printf("A[%d,%d]=%d\n",m,n,A[m][n]);
              }
          }
  }
  </code></pre>
  
  <p>Hello. I am trying to print a 2d array by calling a function print but when I run the program I get:</p>
  
  <p>For the first <code>printf()</code> the correct values:</p>
  
  <pre><code>A[0,0]=25
  A[0,1]=19
  A[0,2]=13
  A[1,0]=4
  A[1,1]=17
  A[1,2]=43
  A[2,0]=7
  A[2,1]=37
  A[2,2]=20
  </code></pre>
  
  <p>But when with the 2nd <code>printf()</code> within the function call of <code>print_array</code> I get:</p>
  
  <pre><code>A[0,0]=25
  A[0,1]=19
  A[0,2]=13
  A[1,0]=0
  A[1,1]=0
  A[1,2]=0
  A[2,0]=0
  A[2,1]=0
  A[2,2]=0
  </code></pre>
  
  <p>Seems like I miss something with pointers... Thanks.</p>