Tic Tac Toe using 2d Array

I have rewritten my tic tac toe console game using a 2d array. I'm having trouble making it work though.

Line 48 to 93 checks to see if the players move is valid, but for some reason unknown to me, it will find all the if statements false, and go to the else. I'm not really sure what to do or why its doing this. I've tried a few google searches but I'm not really sure what to search for.

Here is the pastebin:

http://pastebin.com/0ZVkmgnz


Thanks
~Devin
Last edited on
Are you sure you don't want to check the character literals ('1', '2', etc.) in your if statements, as opposed to integers (1, 2, etc.)?
So, I tried making it like this the first time

if(nextMove == 1 && board[0][0] == '1')

and that didnt work, but it does work like this:


if(nextMove == '1' && board[0][0] == '1')

Thanks for the help!

here is the updated code.

http://pastebin.com/imFaq6pz

could anyone give me a review of this? or some tips/trick/hints? or point out anything that I am doing well. Thanks =D
Last edited on
Here's one I made a while back.

This is the code for checking for a win along with a check for a full board and no winner:
http://sites.google.com/site/davevisone/home/cplusplus/tic---tac---toe#wincheck

The winCheck gets called from the void play( Players *p1, Players *p2, Game *g ) function.

I'm checking for the ascii value of the letters O and X.
http://penguin.dcs.bbk.ac.uk/academic/networks/introduction/units/ascii-full.gif

I used 'for loops' to check it without using more 'if statements'. The first 2 loops check the rows and colums, while the 4 if statements (before the grid check) check for the diagonal wins.
Last edited on
Topic archived. No new replies allowed.