I am getting a segmentation fault on this code and I do not know why : <p>This program is supposed to have a tortoise and hare race each other and print the race out for the user. It is giving me a segmentation fault and I do not know why. I even went through the whole code with a pen and paper to see if it worked and to my knowledge it should work but I am also an amateur to C++ so I do not know.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;stdlib.h&gt; 
#include &lt;ctime&gt;
#include &lt;iomanip&gt;
#define RACE_LENGTH 50

void advanceTortoise(int* ptrTortoise)
{
    int torNum = rand()%10+1;
    if (torNum &lt;= 6)
    {
        *ptrTortoise = *ptrTortoise + 1;
    }else if (torNum = 7) {
        *ptrTortoise = *ptrTortoise + 2;
    }else if (torNum = 8){
        *ptrTortoise = *ptrTortoise + 3;
    }else if (torNum &gt; 8){
        *ptrTortoise = *ptrTortoise;
    if (*ptrTortoise &gt; 50)
    {
        *ptrTortoise = 50;
    }
        return;
    }
}
void advanceHare(int* ptrHare)
{
    int hareNum = rand()%10+1;
    if (hareNum = 1)
    {
        *ptrHare = *ptrHare + 1;
    }else if (hareNum &gt; 1 &amp;&amp; hareNum &lt;= 4){
        *ptrHare = *ptrHare + 2;
    }else if (hareNum &gt; 4 &amp;&amp; hareNum &lt;= 7){
        *ptrHare = *ptrHare + 3;
    }else if (hareNum = 8){
        *ptrHare = *ptrHare - 2;
        if (*ptrHare &lt; 1)
        {
            *ptrHare = 1;
        }

    }else if (hareNum &gt; 8){
        *ptrHare = *ptrHare - 3;
        if (*ptrHare &lt; 1)
        {
            *ptrHare = 1;
        }
    if (*ptrHare &gt; 50)
    {
        *ptrHare = 50;
    }
        return;
    }
}
void printPosition(int* ptrTortoise, int* ptrHare)
{
    if (*ptrTortoise = *ptrHare)
    {
        *ptrTortoise = *ptrTortoise - 1;
    }
    if (*ptrTortoise &gt; *ptrHare)
    {
    std::cout &lt;&lt; std::setw(*ptrHare - 1) &lt;&lt; "H" &lt;&lt; std::setw(*ptrTortoise - *ptrHare) &lt;&lt; "T" &lt;&lt; std::setw(51 - *ptrTortoise) &lt;&lt; "|" &lt;&lt;std::endl;
    }
    if (*ptrHare &gt; *ptrTortoise)
    {
    std::cout &lt;&lt; std::setw(*ptrTortoise - 1) &lt;&lt; "H" &lt;&lt; std::setw(*ptrHare - *ptrTortoise) &lt;&lt; "T" &lt;&lt; std::setw(51 - *ptrHare) &lt;&lt; "|" &lt;&lt;std::endl;
    }
    }
int main()
{
    srand(time(NULL));
    int* ptrTortoise;
    int* ptrHare;
    *ptrTortoise = 1;
    *ptrHare = 1;
    while(*ptrTortoise &lt; 50 &amp;&amp; *ptrHare &lt; 50)
    {
        advanceHare(ptrHare);
        advanceTortoise(ptrTortoise);
        printPosition(ptrTortoise, ptrHare);
    }

    if (*ptrHare = 50)
    {
        std::cout&lt;&lt;"The Hare has won"&lt;&lt;std::endl;
    }else{
        std::cout&lt;&lt;"The Tortoise has won"&lt;&lt;std::endl;
    }
}
</code></pre>
