Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm trying to get this Tic Tac Toe game to continue going. It only goes 1 turn for each player. Also trying to figure out how to program the confirmation that one of the players won and recognize the end the game and if the players want to play again.

What I have tried:

Tried For loop, but it only shows X, no Os, and no definite ending.
Posted
Updated 3-Jun-17 13:43pm
v2
Comments
RAMASWAMY EKAMBARAM 5-Jun-17 2:05am    
I hope you are writing this as a Console program. If you are still learning C, then Win32 GUI is a bad choice - you don't know where (standard) C ends and Win32 API begins.
If you are writing as a Console program on Windows, I can suggest using the freeware Borland C++ compiler version 5.5 (bcc32). Bcc32 works fine on (and at least up to) Windows 7. BCC32 is good for most things but there are lot of bugs in the Date handling functions but that won't come in the way of the game.

The functions gotoxy() and getch() can help you with tic-tac-toe and of course you will need to create an array like: char game[3][3] to match the positions and initialize to spaces (say) to distinguish from filled positions. You can use getch() to read even the Arrow Keys and you can call gotoxy() to position the cursor anywhere on the screen. gotoxy() does not seem to be supported any longer on the other compilers in Windows (GCC or Microsoft C).

If you are bent on writing tic-tac-toe in C this is probably the easiest route other than downloading ready made code from the net!

Advice: Stop trying to do personal projects for now.
Instead, find tutorials and follow them, they will teach you a lot.

Advice: Do not learn programming with C/C++ languages. these languages are more difficult because they don't check anything, YOU are the one that have to care about anything.
With any other language, you can concentrate on learning programming, then when you are tough on programming, go to C/C++, if you want.
Pick one of Visual Basic, C# or Java, they are very popular.

For your project, learn arrays, they will simplify your life.
 
Share this answer
 
Here is an example of a While loop in C: while loop in C[^]
Also see this answer: Tic Tac Toe Tied Games[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900