I'm trying to make a program in C that reads my matrix and calculates the sum of elements, but it gives me an error at scanf("%d",&a[i]). This is the error :
warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘int
(*)[10]’ [-Wformat=]
and this is my code:
#include <stdio.h>
int main() {
int m,n,a[10][10],s=0;
scanf("%d",&n);
scanf("%d",&m);
for(int i=1;i<=n;i )
for(int j=1;j<=m;j )
scanf("%d",&a[i]);
for(int i=1;i<=n;i )
for(int j=1;j<=m;j )
s=s a[i][j];
printf("%d",s);
return 0;
}
Anyone know why?
CodePudding user response:
change scanf("%d",&a[i]);
to scanf("%d",&a[i][j]);
as you need to give him the address to write on but you give the address of array of ten int