tic tac toe game
Mar 29, 2014 at 7:36pm UTC
Hey, so i've started a tic tac toe game. On line 21, "functgame(userinput01,char board[][3];)" i get the following error: error:expected primary-expression before 'char'
thanks in advance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#include <iostream>
#include <cstdlib>
using namespace std;
void functgame(int input, char board[][3]);
int main()
{
int userinput01;
char board[3][3]={{'1' ,'2' ,'3' },{'4' ,'5' ,'6' },{'7' ,'8' ,'9' }};
cout<<board[0][0]<<'|' <<board[0][1]<<'|' <<board[0][2]<<endl;
cout<<board[1][0]<<'|' <<board[1][1]<<'|' <<board[1][2]<<endl;
cout<<board[2][0]<<'|' <<board[2][1]<<'|' <<board[2][2]<<endl;
cout<<"Welcome. Pick your square to start the game: " <<endl;
cin>>userinput01;
functgame(userinput01,char board[][3]);
}
void functgame(int input,char board[][3])
{
if (input==1)
{
board[0][0]='X' ;
}
cout<<board[3][3];
}
Mar 29, 2014 at 7:49pm UTC
Remove the keyword char
on line 21. Type specifications are not used in a function call.
Mar 29, 2014 at 7:58pm UTC
then i get the error: "expected primary expression before ']' token"
Mar 29, 2014 at 10:03pm UTC
Pass board without the []'s.
functgame(userinput01,board);
Last edited on Mar 29, 2014 at 10:03pm UTC
Mar 30, 2014 at 4:31am UTC
thank you very much. i dont quite understand that but thanks
Topic archived. No new replies allowed.