The error: type of formal parameter 1 is incomplete means you have not mentioned the second (column) dimension of a 2D array
In C, it is necessary to mention the second(column)dimension, whereas the first dimension(row) is optional
So, that means you should always mention the second (column) dimension during function declaration or initializing a 2D array to avoid error
Let’s see an example
#include <stdio.h>
#include <stdlib.h>
void display(int q[][],int,int);
int main()
{
int a[3][4]={{1,2,3,4},{5,6,7,8},{9,0,1,6}};
display(a,3,4);
return 0;
}
// function declaration Without mentioning the second(column)dimension of a 2D array
void display(int q[][],int row, int col)
{
int i, j;
for (i=0;i<row;i++)
{
for(j=0;j<col;j++)
printf("%d",q[i][j]);
printf("\n");
}
printf("\n");
}
As can be seen, from the above code the second (column) dimension is missing in the function declaration
It is illegal omit the second (column) dimension and because, of that such errors are produced
Finally, the error can be fixed by simply mentioning the second (column) dimension of a 2D array during function declaration
#include <stdio.h>
#include <stdlib.h>
void display(int q[][4],int,int);
int main()
{
int a[3][4]={{1,2,3,4},{5,6,7,8},{9,0,1,6}};
display(a,3,4);
return 0;
}
// function declaration Without mentioning the second(column)dimension of a 2D array
void display(int q[][4],int row, int col)
{
int i, j;
for (i=0;i<row;i++)
{
for(j=0;j<col;j++)
printf("%d",q[i][j]);
printf("\n");
}
printf("\n");
}
Leave a Reply