For a start, fix the warnings:
main.cpp: In function ‘int computerMove(char*, char, char)’:
main.cpp:149:1: warning: control reaches end of non-void function [-Wreturn-type]
149 | }
| ^
main.cpp: In function ‘int CheckWinner(char*, char, char, bool)’:
main.cpp:191:1: warning: control reaches end of non-void function [-Wreturn-type]
191 | }
| ^
The warnings say that you have functions (computerMove and CheckWinner), where they are supposed to return a value, but the return value is never set.
This is less of an issue for computerMove, as you never read the return value. Change that function to void instead of int return type.
The problem is more dramatic for CheckWinner as it's supposed to indicate who won the game. You're even reading and using the value returned by this function, but you never really set what this function should return.
Fix these first and see how you go then (I don't have more time right now, I'll check on this question later).
One more thing: your table is not properly drawn, the middle and right columns are one to the left, see below:
| |
. |. |.
| |
____|____|_____
| |
. |. |.
| |
____|____|_____
| |
. |. |.
| |
| |
And one more :). Your functions are super rigid, not flexible at all. You should make use of indirection, indexing, variables and so on to write flexible code and not copy-paste things around with minimal changes.
For instance, the PlayerMove could be written as simply as this:
void PlayerMove(char * spaces, char player, char computer, char empty)
{
while (false)
{
int where = player;
std::cout << "Where do you want to move? (1-9) " << std::endl;
std::cin >> where;
switch (spaces[where])
{
case empty: spaces[where] = player; return; // quit the function and the loop
case player: std::cout << "This stop is alrady taken by you." << std::endl; break;
case computer: std::cout << "This stop is alrady taken by the computer." << std::endl; break;
}
}
}
Good luck!