How to Replace Bits of Strings

Jun 5, 2015 at 10:58pm
I am making a tic-tack-toe game, and I don't know how to make the board replace a space with an x or an o. For example, I need the board, which one row looks like this
| | | |
-------
to be able to change to this
|X| | |
-------
and be able to put the X(or O) anywhere that the space is on the line.
Last edited on Jun 6, 2015 at 12:11am
Jun 5, 2015 at 11:51pm
How are you storing your string?

And how are you displaying it, for that matter?

Andy
Last edited on Jun 6, 2015 at 10:47am
Jun 6, 2015 at 12:18am
I have a string called board_lines that is the | | | |
and another string called board_dashes that is the -------
They make up the board by putting them all together with cout.

I'm trying to make a function where you select where you want the X to be in the column by using numbers that correspond to where it would be on the board. For example, if you wanted an X in the first column, you would say that you wanted it in position 2.
Jun 6, 2015 at 1:00am
Have you looked at how other people have done it?
http://runnable.com/U_bAcOEL2s1XrnH_/c%2B%2B-tic-tac-toe-game-for-array
Topic archived. No new replies allowed.