Trouble passing data from if and if else
<p>I'm trying to create a simple tic tac toe program as part of some homework but having difficulty in checking whether or not the game has been won. As soon as I launch the program and enter a number, it straight away says "Player 2 wins!" and I can't see what I have done wrong.</p>

<pre><code>#include "stdafx.h"
#include "tictactoe.h"

using namespace std;

void clearBoard(char gameBoard[])
{
    for (int i = 0; i &lt; board_size; i++)
    {
        gameBoard[i] = free_char;
    }
}

void printBoard(char gameBoard[])
{
    system("cls");

    //for (int i = 0; i &lt; board_width; i++)
    //{
        //cout &lt;&lt; gameBoard[i] + 1 &lt;&lt; " " &lt;&lt; gameBoard[i] + 1 &lt;&lt; " " &lt;&lt; gameBoard[i] + 1 &lt;&lt; endl;
    //}

    cout &lt;&lt; gameBoard[0] &lt;&lt; " " &lt;&lt; gameBoard[1] &lt;&lt; " " &lt;&lt; gameBoard[2] &lt;&lt; endl;
    cout &lt;&lt; gameBoard[3] &lt;&lt; " " &lt;&lt; gameBoard[4] &lt;&lt; " " &lt;&lt; gameBoard[5] &lt;&lt; endl;
    cout &lt;&lt; gameBoard[6] &lt;&lt; " " &lt;&lt; gameBoard[7] &lt;&lt; " " &lt;&lt; gameBoard[8] &lt;&lt; endl;
}

int askMove(int player)
{
    cout &lt;&lt; "Player " &lt;&lt; player &lt;&lt; ", Select a square [1-9]: ";
    cin &gt;&gt; choice;

    return 0;
}

bool verifyMakeMove(char gameBoard[], int move, int player)
{
    if (player == 1)
    {
        mark = p1_char;
    }
    else
    {
        mark = p2_char;
    }

    if (move &lt; 1 || move &gt; 9)
    {
        cout &lt;&lt; "You did not enter a number between 1 and 9. Try again." &lt;&lt; endl;
    }

    if (move == 1 &amp;&amp; gameBoard[0] == free_char)
    {
        gameBoard[0] = mark;
    }
    else if (move == 2 &amp;&amp; gameBoard[1] == free_char)
    {
        gameBoard[1] = mark;
    }
    else if (move == 3 &amp;&amp; gameBoard[2] == free_char)
    {
        gameBoard[2] = mark;
    }
    else if (move == 4 &amp;&amp; gameBoard[3] == free_char)
    {
        gameBoard[3] = mark;
    }
    else if (move == 5 &amp;&amp; gameBoard[4] == free_char)
    {
        gameBoard[4] = mark;
    }
    else if (move == 6 &amp;&amp; gameBoard[5] == free_char)
    {
        gameBoard[5] = mark;
    }
    else if (move == 7 &amp;&amp; gameBoard[6] == free_char)
    {
        gameBoard[6] = mark;
    }
    else if (move == 8 &amp;&amp; gameBoard[7] == free_char)
    {
        gameBoard[7] = mark;
    }
    else if (move == 9 &amp;&amp; gameBoard[8] == free_char)
    {
        gameBoard[8] = mark;
    }
    else
    {
        cout &lt;&lt; "That move cannot be made. Try again." &lt;&lt; endl;
    }

    return 0;
}

int checkEndGame(char gameBoard[])
{
    if (gameBoard[0] == gameBoard[1] &amp;&amp; gameBoard[1] == gameBoard[2])
    {
        return 1;
    }
    else if (gameBoard[3] == gameBoard[4] &amp;&amp; gameBoard[4] == gameBoard[5])
    {
        return 1;
    }
    else if (gameBoard[6] == gameBoard[7] &amp;&amp; gameBoard[7] == gameBoard[8])
    {
        return 1;
    }
    else if (gameBoard[0] == gameBoard[3] &amp;&amp; gameBoard[3] == gameBoard[6])
    {
        return 1;
    }
    else if (gameBoard[1] == gameBoard[4] &amp;&amp; gameBoard[4] == gameBoard[7])
    {
        return 1;
    }
    else if (gameBoard[2] == gameBoard[5] &amp;&amp; gameBoard[5] == gameBoard[8])
    {
        return 1;
    }
    else if (gameBoard[0] == gameBoard[4] &amp;&amp; gameBoard[4] == gameBoard[8])
    {
        return 1;
    }
    else if (gameBoard[2] == gameBoard[4] &amp;&amp; gameBoard[4] == gameBoard[6])
    {
        return 1;
    }
    else if (gameBoard[0] != free_char &amp;&amp; gameBoard[1] != free_char &amp;&amp; gameBoard[2] != free_char &amp;&amp; gameBoard[3] != free_char &amp;&amp; gameBoard[4] != free_char &amp;&amp; gameBoard[5] != free_char &amp;&amp; gameBoard[6] != free_char &amp;&amp; gameBoard[7] != free_char &amp;&amp; gameBoard[8] != free_char)
    {
        return -1;
    }
    else
    {
        return 0;
    }
}

int playGame()
{
    char gameBoard[10];

    int player = 1;

    int winner;

    clearBoard(gameBoard);

    do
    {
    printBoard(gameBoard);

    askMove(player);

    verifyMakeMove(gameBoard, choice, player);

    checkEndGame(gameBoard);

    if (player == 1)
    {
        player = 2;
    }
    else
    {
        player = 1;
    }
    } while (checkEndGame(gameBoard) == 0);

    if (checkEndGame(gameBoard) == 1)
    {
        cout &lt;&lt; "Player " &lt;&lt; player &lt;&lt; " wins!" &lt;&lt; endl;
    }
    else
    {
        cout &lt;&lt; "It's a draw!" &lt;&lt; endl;
    }

    return 0;
}

int main()
{
    playGame();

    return 0;
}
</code></pre>
