Hi, I have been given a project to finish in school in 3 phases, the thing is I am not that good when it comes to programing. The project was to develope a tic tac toe game as following:

**Phase 1:
Write a program that will first ask the user to choose their character ‘x’ or ‘o’, as follows:
Enter your favourite character ‘x’ or ‘o’: x
Then, the program should display the following tic-tac-toe board on the screen:
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |
Next, ask the user to enter his/her selection, and based on the input, the program displays the
following output:
Enter your selection: 5
| 1 | 2 | 3 |
| 4 | x | 6 |
| 7 | 8 | 9 |

If the user selects a space that is already occupied by a symbol ( ‘o’ or ‘x’), the program
should display an error message such as, “The selected position is already taken”.
The program should terminate after five selections are made.**

This is my first programming class and I am already facing diffuclty in such a simple task. I have basic knowledge of if statemets and loops. But can't really understand bool and "void".
I keep seeing other posts mentioning "arrays & char board[3][3]". I don't really know what that is. is there any other ways to make a tic tac toe without that?

While writing a code would be nice, I am more willing to learn, as such, an explanation of how you wrote the code would be even better!

I am using visual c++ if that amounts to anything.

Recommended Answers

All 3 Replies

In the case of common apps like Tic-Tac-Toe I might defer to https://rosettacode.org/wiki/Tic-tac-toe but if you were to supply other folk's code you would indeed be missing out on the real reason you took the course. I won't tell you why here.

I think the object of school assignments is that you do them yourself

What you shown here is an array, with 9 elements.
(You can make array with ten "drawers" (from 0 to 9), and use from 1st to 9th.)

Array can contain digits (I didn't say "numbers"), from 1 to 9 in those places.
When you select position 5, check if there is digit, not X or O.
(If select position 3, before putting "X" or "O", check if it's "3" in there.)

So, array can't contain numbers, because X and O aren't numbers, and they have to go in.
What it can contain then?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.