1. ## Check my Tic Tac Toe game for bugs please

it is at this thread http://www.cprogramming.com/cboard/s...654#post49010. Thanks everyone that uses it

Ryan

2. ## ;)

Could you try making that code a little bit better... I get 12 compilation errors, even after taking out all of those stray escape sequences.

Rewrite it and put it in [quote] tags.

3. The return from the getgrid() is an int between 1-9
this is then used in a long if / else statement.

A better way would be to use a math aproach.

If you use a combo of / (divide) and % (remainder) you can work out the grid refrence.

ie say 2 returned. This is array[0][1] in a zero based index.
So to get this refrence
1. Reduce the return from a one based to zero based index by subtracting 1 from it
->2-1 = 1
2. Divide by MAXCOLUMN to get the column
->1/3 = 0
3. Find the remainder for the row index
->1%3 = 1

say we have 9 returned
9-1 = 8
8/3 = 2
8%3 = 2

or Array[2][2] (remember is zero based eg 0-2)

Will reduce the lenght of the code.

PS Never, EVER, put msgbox's with comments like that in your code. It may be your work but...

One programmer working for Apple left one like that in a product and it was released. As soon as a customer saw it they were sacked. Better to be safe than sorry. (I have been working on the same program for over two years now. Can't remember all the msgbox's.)

4. Mine worked on my computer what do you mean by stray escape sequences??? Thanks

Ryan

5. Here it is compiled

6. The compiler wouldn't take the \ as a continuation at school so I am wondering if that is what you are having problems with here is the revised version.

#include <iostream.h>

#ifndef __CHECKTACK_H__
#define __CHECKTACK_H__

#define CHECKTACKX(a, b) if(grid[a][b] == ' ') {grid[a][b] = 'X'; fplayer += 1;} else {cout << filled << '\n'; continue;}

#define CHECKTACKO(a, b) if(grid[a][b] == ' ') {grid[a][b] = 'O'; fplayer -= 1;} else {cout << filled << '\n'; continue;}

#endif