Feedback on my Tic Tac Toe C++ program

Hi i'm a beginner at c++ so although my program works i'd like some feedback on my code. So if you could have a look and point out anything sloppy ;).
Its supposed to be a two player tic tac toe.

Many thanks.
Get rid of the #include <stdafx.h> garbage that VS puts in there. You don't need it.

Lines 45..46 should read something like
		cout << "Press ENTER to start a new game." << endl;
		cin.ignore( numeric_limits <streamsize> ::max(), '\n' );
You will have to #include <limits> to use that second line.

I notice, however, that your program does not give the user the option to quit at any time, except by killing the program with a Ctrl-C. This is fine, but I usually prefer to give the user a nicer way out.

The numbering of the boxes is currently '0'..'8'. I would change it to something like '1'..'9', just so that the naught ('O') isn't ever confused with the zero ('0'). Even with the stupid line or dot or whatever the console does to it, they are still hard to distinguish visually.

The game does not terminate if it ends in a tie. You need to add a condition to check to see whether or not all boxes were filled.

Hope this helps.
Thanks for the reply.

cin.ignore( numeric_limits <streamsize> ::max(), '\n' );

Should go before or after

cin >> chInput;

I could only think of a way to exit between games which involved some if statements and a 'break'. So if you could point me to a better method that would be nice :D.

and finally, I forgot about ties :D thanks!
Last edited on
Topic archived. No new replies allowed.