This program is giving me a dodgy output, its meant to be a board of numbers. Thank you.
using namespace std;
char firstplayermark = 'x';
char secondplayermark = 'O';
char squareone = 1;
char squaretwo = 2;
char squarethree =3;
char squarefour =4;
char squarefive = 5;
char squaresix = 6;
char squareseven = 7;
char squareeight = 8;
char squarenine = 9;
bool bGamenotover = true;
cout << "Hello, welcome to Tic Tac Toe, enter a value (values from 1-9 and row-based e.g. first row: 1-3 second row: 4-6 third row: 7-9) on the board to place an X (if you are player 1 who always starts first) or an O (if you are player twowho always starts second)" << endl << "Would you like to start playing? .yes. .no.";
cin >> Continue;
Im sorry I couldn't elaborate on my description how the word limit wouldnt let me! Any help is greatly appreciated, Im new to C++ and I am in an awkward position now where I cant really progress as Im unable to isolate this problem. It is meant to be a Tic Tac Toe board with the outcome of numbers 1-9, however it seems to be outputting a load of upside down crosses. Im very confused as a previous version worked however it has suddenly messed up when I added a checking system if someone had won including a boolean value. Thank you!
Those weird output characters are the chars you tell the program to print.
Look at this:
char a = 1
cout << a << endl;
You assign the value 1 to the char. This is a "control character", which is unprintable. Note that this is no the same as the char "1", but the character whose numeric value is 1 (look here for the value of chars: http://www.asciitable.com/).
Your program has many things that could be improved, I'll point some of them:
There is no need to assign the numbers to the "square" variables. Why don't you initialize them with a single space? That would solve your print problem
You have a lot of sentences like this one: firstplayermark == squarefour && squarefive && squaresix
This is wrong, you don't want to make a logical operation between the square values. It will always return true, as long as all the variables have some value.
This is what you want: firstplayermark == squarefour && firstplayermark == squarefive && firstplayermark == squaresix
The program can be A LOT shorter. Put the commonly used code in a subroutine, and remove duplicated code when possible.
Thank you so much for the help as the char values issue would have been hard to spot without it aswell as the player mark detail. This has not only made my program work, but will greatly aid me in the future!