I am a beginnger programmer and I am trying to write a program that will initialize a 2-dimensional array with zeros. Also, it will use a function to do the intializing. Unfortunately I can't get it to work.
Here is the code I have so far:
Code:
#include <stdio.h>
#define M 10
#define N 5
void InitializeArray2D ( int array[][N], int r, int c);
void main()
{
int a [M][N];
InitializeArray2D (a,M,N);
}
void InitializeArray2D (int array [][N], int r, int c) {
int i,j;
for (i=0; i<r; i++){
for (j=0; j<c; j++){
int array [i][j] = 0;
}
}
printf("%d", array[1][1]); /*test to see if initialization worked*/
}
Any help would be greatly appreciated!!
Thanks...
Phil