How do i solve this segmentation fault? : <p>i have been trying to figure out what is wrong with my piece of code. So taking in and out of my code everywhere, i think i have found the culprit. it is this chunk of code here that is causing it</p>

<pre><code>   if (strcmp(input, "load 1") != 0 || strcmp(input, "load 2") != 0 || strcmp(input, "quit") != 0)
    {
        Player player;
        Position position;
        Direction direction;

        char* tok;
        char* firstInput=0;
        char* secondInput=0;
        char* thirdInput=0;
        char* fourthInput=0;
        int x;
        int y;
        char str[10];
        char str2[10];


        tok = strtok(input, " ");
        strcpy(firstInput, tok);            
        tok = strtok(NULL, ", ");
        strcpy(secondInput, tok);          
        tok = strtok(NULL, ", ");
        strcpy(thirdInput, tok);          
        tok = strtok(NULL, "");
        strcpy(fourthInput, tok);            

        strcpy(str, secondInput);
        x = atoi(str);
        strcpy(str2, thirdInput);
        y = atoi(str2);

        if(strcmp(firstInput, "init") == 0 )
        {
            if(x &gt;= 0 &amp;&amp; x &lt;= 9)
            {
                if(y &gt;= 0 &amp;&amp; y &lt;= 9)
                {
                    if (strcmp(fourthInput,"north") == 0 || (strcmp(fourthInput,"south")) || (strcmp(fourthInput,"west") == 0) || (strcmp(fourthInput,"east") == 0))
                    {
                        position.x = x;
                        position.y = y;

                        if(strcmp(fourthInput,"north") == 0)
                        {
                            direction = NORTH;
                        }
                        if(strcmp(fourthInput,"south") == 0)
                        {
                            direction = SOUTH;
                        }
                        if(strcmp(fourthInput,"west") == 0)
                        {
                            direction = WEST;
                        }
                        if(strcmp(fourthInput,"east") == 0)
                        {
                            direction = EAST;
                        }
                        initialisePlayer(&amp;player, &amp;position, direction);
                        placePlayer(board, position);
                        displayDirection(direction);
                    }
                }
            }
        }                      
    }
</code></pre>

<p>from what i know segmentation fault means a memory problem. I have made sure there is enough space for everything. what is actually going on?</p>
