Well in both Dev C++ and Code::Blocks I get an error from the code below. I wrote the code as exact as possible like what I see in my book(C how to program 6th edition). Can some1 explain the reason for these warning messages?
Code:
#include <stdio.h>
void printArray(const int a[][3]);
int main(void)
{
int array1[2][3] = {{1,2,3}, {4,5,6}};
int array2[2][3] = {1,2,3,4,5};
int array3[2][3] = {{1,2,}, {4}};
printf("Values in array1 by row are:\n");
printArray(array1);
printf("Values in array2 by row are:\n");
printArray(array2);
printf("Values in array3 by row are:\n");
printArray(array3);
return 0;
}
void printArray(const int a[][3])
{
int i;
int j;
for(i = 0; i <= 1; i++)
{
for(j = 0; j <= 2; j++)
{
printf("%d", a[i][j]);
}
printf("\n");
}
}
The warnings are:
warning: passing argument 1 of 'printArray' from incompatible pointer type[enable by default]
note: expected 'const int (*)[3]' but argument is of type 'int (*)[3]'
shoes for each function calling