Passing a two-dimensional array as an argument in C

Array can also be passed to the function. To pass an array, you need to specify the name of the array and the size of the array in actual arguments. The corresponding formal arguments will also have array with two subscripts, size of first subscript can be omitted, a variable to hold the row size and a variable to hold the column size. The three arguments in the actual arguments list.

 

#include<conio.h>

#include<stdio.h>

void main()

{

   void displayy(int[2][3],int,int);

   int a[2][3]={{11,12,13},{22,23,24}};

   clrscr();

   displayy(a,2,3);

   getch();

}

void displayy(int bb[2][3],int rr,int cc)

 {

   int ii,jj;

   printf("\n the array is\n");

   for(ii=0;ii<rr;ii++)

   {

     for(jj=0;jj<cc;jj++)

     {

       printf("%d\t",bb[ii][jj]);

     }

     printf("\n");

  }

}

Output...

Two dimensional array as an argument