Reputation: 13
I made a function which creates a game board and want to call it on my main. Also, the variable that it uses is a global variable defined outside the main (char board[3][3])
I tried defining char board[3][3] inside main as well but the error keeps appearing, and I don't want to use it as a local variable of the function since I use it in other functions (that i ommited in this portion of code) as well
char board[3][3] = {'1','2','3','4','5','6','7','8','9'};
void Tablero(char board[3][3]) {
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
if(j < 2){
printf(" %c |",board[i][j]);
}
else{
printf(" %c",board[i][j]);
}
}
if(i < 2){
printf("\n-----------------------\n");
}
}
}
int main (){
Tablero(char board[3][3]);
return 0;
}
the error that appears is
tictactoe.c: In function 'main':
tictactoe.c:203:10: error: expected expression before 'char'
Tablero(char board[3][3]);
Upvotes: 1
Views: 301
Reputation: 311078
This in main
Tablero(char board[3][3]);
is an incorrect function declaration with an absent return type.
I think you mean the call of the function instead of the declaration
Tablero( board );
Upvotes: 3