Пытаюсь научить себя, как передать массив из int main()
в функцию, и я просто не понимаю этого.
Вот мой код.
#include <stdio.h>
void printboard( char *B ) {
/*Purpose: to print out the tic tac toe board B
*/
int i,j;
printf("\n");
for (i=0;i<3;i++) {
for (j=0;j<3;j++) {
printf( " %c ",B[i][j]);
}
printf("\n\n");
}
}
int main( void ) {
char B[3][3] = { '-','-','-',
'-','-','-',
'-','-','-' };
printboard(B);
}
Я получаю эту ошибку:
test.c: In function 'printboard':
test.c:12: error: subscripted value is neither array nor pointer
test.c: In function 'main':
test.c:25: warning: passing argument 1 of 'printboard' from incompatible pointer type
Просто нужно понять, как работают указатели и как они передаются, чтобы я мог продолжить работу.