Problems with multi. arrays/conditions

I'm trying to make a simple tic tac toe game and I'm trying to make it so that if the user inputs any number not on the board not (1-9), that they recieve an error code. However, the underlined condition is turning out to be be false ( does not cout error code) no matter what number I input.

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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
 #include <cstdlib>
#include <iostream>

using namespace std;
int move;
int board [4] [4];
int space1;
int space2;
int space3;
int space4;
int space5;
int space6;
int space7;
int space8;
int space9;

int xaxis (int a)
{
if(a=1)
{return(0);}
else if (a=2)
{return(1);}
else if (a=3)
{return(2);}
else if (a=4)
{return(0);}
else if (a=5)
{return(1);}
else if (a=6)
{return(2);}
else if (a=7)
{return(0);}
else if (a=8)
{return(1);}
else if (a=9)
{return(2);}
else
{return(3);}
}

int yaxis (int a)
{ 
if (a=1)
{return(0);}
else if (a=2)
{return(0);}
else if (a=3)
{return(0);}
else if (a=4)
{return(1);}
else if (a=5)
{return(1);}
else if (a=6)
{return(1);}
else if (a=7)
{return(2);}
else if (a=8)
{return(2);}
else if (a=9)
{return(2);}
else
{return(3);}  
}

int main(int argc, char *argv[])
{
cout <<"Tic-Tac-Toe\n  |   |\n 1  2  3\n  |   |\n---------\n  |   |\n 4  5  6\n  |   |\n----------\n  |   |\n 7  8  9\n  |   |\n";  
cout << "Player 1, please enter a number\n";
cin >> move;
board [xaxis (move)] [yaxis (move)] = 2;
if (board [3] [3]>0)
{cout << "\nError: Please choose a number from 1-9\n";}




    system("PAUSE");
    return EXIT_SUCCESS;
}
Last edited on
x = y assigns the value of y to x.
x == y is true if and only if the values of x and y are equal.
Check every if statement in xaxis() and yaxis().
That worked thanks
Topic archived. No new replies allowed.