This c code
int rhdDEboard2(){
int board[64]={0};
int rc;
printf("\n");
for (rc=0;rc<8;rc++)
printf("\t %i %i %i %i %i %i %i %i\n",board[rc]);
printf("\n");
return 0;
}
compiled with MinGW in Win8 PC gives this error: : warning: format '%i' expects a matching 'int' argument [-Wformat]
I do not understand why! The board array is declared as type int..isn't it? (Does C treat the array as a pointer type?). I have tried using %p as format specifier but that doesn't work and nor does using %d. I understand what the warning says, but not why it says it, nor how to fix it, and feel I must be missing something quite basic, simple and straightforward here, but I do not understand this compiler warning.I'm grateful for help to try and get me to understand this C compiler warning and how I should fix it..many thanks
As commenters mentioned, you should try any of the way.
int rhdDEboard2() {
int board[64]={0};
int i,j;
printf("\n");
for (i=0;i<8;i++) {
printf("\t");
for(j=0;j<8;j++)
printf(" %i",board[(i*8)+j]);
printf("\n");
}
printf("\n");
return 0;
}
or
int rhdDEboard2() {
int board[64]={0};
int rc;
printf("\n");
for (rc=0; rc<64; rc+=8)
printf("\t %i %i %i %i %i %i %i %i\n",
board[rc] ,board[rc+1],board[rc+2],board[rc+3],
board[rc+4],board[rc+5],board[rc+6],board[rc+7] );
printf("\n");
return 0;
}