i'm trying to compile a function to populate a matrix with zeros and ones as part of an adjacency matrix assignment but i keep getting errors when i use the make comma
this is the function that i have in a populateMat.c file.
#include "defs.h"
void PopulateMat(adjmat *mat[N][N]){
printf("\n the matrix size is [%d] x [%d]\n please enter connections between nodes.\n", N,N);
int i;
int j;
for ( i = 0; i < N ;i++){
for ( j = 0; j < N ;j++)
{
printf("\n is there a connection between node %d to node %d ?\n yes - 1 \n no - 0\n", i, j);
scanf("%d", mat[i][j]);
if (!(&mat[i][j]==0 || (int)&mat[i][j]==1)) {
printf("\n%d",mat[i][j]);
printf("wrong indication inserted.\n insert 1 for yes \n 0 for no ");
j--;
}
}
}
}
and this is the error when i run gcc -Wall -ansi -pedantic populateMat.c
populateMat.c: In function ‘PopulateMat’: populateMat.c:13:19: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘int (*)[3][3]’ [-Wformat=] scanf("%d", mat[i][j]); ^ populateMat.c:15:24: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int (*)[3][3]’ [-Wformat=] printf("\n%d",mat[i][j]); ^ /usr/lib/gcc/i686-linux-gnu/5/../../../i386-linux-gnu/crt1.o: In function `_start': (.text+0x18): undefined reference to `main' collect2: error: ld returned 1 exit status
my main.c is
int main()
{
adjmat mat; // defined in defs.h
typedef int adjmat [N][N];
PopulateMat(&mat);
printf("adjacency matrix received");
// הדפסת מטריצת שכנויות
printMat(mat);
adjacency(&mat);
return 0;
}
and Clion is giving this warning about populateMat(&mat) ** incompatible pointer types passing 'adjmat ' (aka 'int ()[3][3]') to parameter of type 'adjmat ()[3]' ** i've been trying to figure it out for way to long, help!