Tictactoe program error

I'm trying to write a tictactoe program. It isnt complete, not even halfway but whenever i try to build it, it shows an error

expected primary expression before "{"token. im not able to fix it pls help






#include<iostream>
using namespace std;


int y;
char board [3][3];

void start()
{
cout<<"So you wanna play a game of tictactoe. You are X I'm o."<<endl;
cout<<" 1 2 3"<<endl;
cout<<" 4 5 6"<<endl;
cout<<" 7 8 9"<<endl;
cout<<"Type the number that corresponds to your position"<<endl;
}

void readmove()
{
cin>>y;
switch (y)
{
case 1:
board [0][0] = {X};
break;

case 2:
board [0][1] = {X};
break;

case 3:
board [0][2] = {X};
break;

case 4:
board [1][0] = {X};
break;

case 5
board [1][1] = {X};
break;

case 6:
board [1][2] = {X} ;
break;

case 7:
board [2][0] = {X};
break;

case 8:
board [2][1] = {X};
break;

case 9:
board [2][2] = {X};
break;

default:
cout<< "invalid move"<<endl;

}
}
int main()
{
start();
}




Last edited on

board[2][0] = { X }; is incorrect, you should assign a value to arrays like this:

board[2][0] = 'X';


ok thanks
Topic archived. No new replies allowed.