Hi I am making a program that uses multi dimensional arrays to display numbers from 1 to 54 in 6 rows and 9 columns. Here is my code:
Code:
#include <stdio.h>
#define MAXCOL 6
#define MAXROW 9
void fillArray(int array[][MAXROW]);
void printArray(int array[][MAXCOL]);
int main()
{
int array[MAXROW][MAXCOL];
fillArray(array);
printArray(array);
return 0;
}
void fillArray(int array[][MAXROW])
{
/* fill the array with the numbers 1 to 54
in ascending order going from left to right
then top to bottom. Therefore 1 will be in
the top left hand corner, 6 in the top right
hand corner, 49 in the bottom left corner
and 54 in the bottom right hand corner.
*/
}
void printArray(int array[][MAXCOL])
{
int row, col;
int size = 1;
printf("\n");
for (row=0; row<=MAXROW; row++)
{
for (col=0; col<=MAXCOL; col++)
{
array[row][col]=size;
printf("%9d",array);
}
printf("\n");
}
}
It gives me an error in line 13: array.c(13): error #2140: Type error in argument 1 to 'fillArray'; found 'int [6] *' expected 'int [9] *'.
I am not sure why? I have tried changing the MAXCOLS AND MAXROWS around but it's not doing anything except giving more errors.
Please help.