Introduction
Simply define a size of the array in the function header like this:
void someFunc(int buff[3][2])
and make a call to the function with another two dimensional array:
void add(int swap[3][2], int swap2[3][2])
{
int temp,i;
for (i=0; i<3; i++)
{
temp = swap[i][0];
swap[i][0] = swap[i][1];
swap[i][1] = temp;
}
return;
}
void display(int array[3][2],int array2[3][2] )
{
int count=0,count1=0;
for (count=0;count<3;count++)
for (count1=0;count1<2;count1++)
printf("%d ", array[count][count1]);
printf("\n");
puts("");
}
int main()
{
int i[3][2]= { {1,2}, {3,4}, {5,6} };
display(i,i);
add(i,i);
display(i,i);
return 0;
}
History
- 8th May, 2010: Initial post