I used a multi dimensional array:

``int grid;``

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

``````grid = 2;
grid = 2;
grid = 2;
grid = 2;
grid = 2;
grid = 2;
grid = 2;
grid = 2;
grid = 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 = 2){printf("\n_");}
if(grid = 1){printf("\nX");}
if(grid = 0){printf("\nO");}
if(grid = 2){printf("_");}
if(grid = 1){printf("X");}
if(grid = 0){printf("O");}
if(grid = 2){printf("_");}
if(grid = 1){printf("X");}
if(grid = 0){printf("O");}
if(grid = 2){printf("\n_");}
if(grid = 1){printf("\nX");}
if(grid = 0){printf("\nO");}
if(grid = 21){printf("X");}
if(grid = 0){printf("O");}
if(grid = 2){printf("_");}
if(grid = 1){printf("X");}
if(grid = 0){printf("O");}
if(grid = 2){printf("\n_");}
if(grid = 1){printf("\nX");}
if(grid = 0){printf("\nO");}
if(grid = 2){printf("_");}
if(grid = 1){printf("X");}
if(grid = 0){printf("O");}
if(grid = 2){printf("_");}
if(grid = 1){printf("X");}
if(grid = 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.

## Recommended Answers

use double-equals in the comparison.
==

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

## All 3 Replies

use double-equals in the comparison.
==

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

Comparison must use double equals sign like:

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

use double-equals in the comparison.
==

``if(grid == 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.