I used a multi dimensional array:

``int grid[3][3];``

then I assigned all the variables in the array to the number 2 like this:

``````grid[0][0] = 2;
grid[0][1] = 2;
grid[0][2] = 2;
grid[1][0] = 2;
grid[1][1] = 2;
grid[1][2] = 2;
grid[2][0] = 2;
grid[2][1] = 2;
grid[2][2] = 2;``````

not the most efficient way, I know, but that is what I did.
Then I tried to print letters corresponding to their numbers:

``````if(grid[0][0] = 2){printf("\n_");}
if(grid[0][0] = 1){printf("\nX");}
if(grid[0][0] = 0){printf("\nO");}
if(grid[0][1] = 2){printf("_");}
if(grid[0][1] = 1){printf("X");}
if(grid[0][1] = 0){printf("O");}
if(grid[0][2] = 2){printf("_");}
if(grid[0][2] = 1){printf("X");}
if(grid[0][2] = 0){printf("O");}
if(grid[1][0] = 2){printf("\n_");}
if(grid[1][0] = 1){printf("\nX");}
if(grid[1][0] = 0){printf("\nO");}
if(grid[1][1] = 21){printf("X");}
if(grid[1][1] = 0){printf("O");}
if(grid[1][2] = 2){printf("_");}
if(grid[1][2] = 1){printf("X");}
if(grid[1][2] = 0){printf("O");}
if(grid[2][0] = 2){printf("\n_");}
if(grid[2][0] = 1){printf("\nX");}
if(grid[2][0] = 0){printf("\nO");}
if(grid[2][1] = 2){printf("_");}
if(grid[2][1] = 1){printf("X");}
if(grid[2][1] = 0){printf("O");}
if(grid[2][2] = 2){printf("_");}
if(grid[2][2] = 1){printf("X");}
if(grid[2][2] = 0){printf("O");}``````

but when I run it it gives me this:

_
X_X_X
_
X_X_X
_
X_X_X

what is wrong and how do I fix it? Thanks.

use double-equals in the comparison.
==

``if(grid[0][0] == 2){printf("\n_");}``

## All 3 Replies

use double-equals in the comparison.
==

``if(grid[0][0] == 2){printf("\n_");}``

Comparison must use double equals sign like:

``````if(grid[0][0][B]==[/B]2){printf("\n_");}
if(grid[0][0][B]==[/B]1){printf("\nX");}``````

use double-equals in the comparison.
==

``if(grid[0][0] == 2){printf("\n_");}``

thanks, it works now!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.