I get a segmentation fault when I compile and try to run this code : <p>This is a part of my code:</p>

<pre><code>for(i = 0; i &lt; rows; i++)
{
    for(j = 0; j &lt; columns; j++)
    {
        for(k = 0; k &lt; rows - i &amp;&amp; k &lt; columns - j; k++)
        {
            if(i + k &gt; rows || j + k &gt; columns) break;
            if(b-&gt;board[i + k][j + k] == 1) counter++;
            if(b-&gt;board[i + k][j + k] == 2) counter = 0;
            if(counter &gt; max_pd)
            {
                plh = counter;
                jkee = j;
                kkee = k;
            }
        }
        counter = 0;
    }
    if(plh &gt; max_pd)
    {
        max_pd = plh;
        plh = 0;
        for(n = 0; n &lt; 1; n++)
        {
            if(i + kkee &gt; rows || jkee + kkee + 1 &gt; columns) break;
            if(b-&gt;board[i + kkee + 1][jkee + kkee + 1] == 0 &amp;&amp; b-&gt;board[i + kkee][jkee + kkee + 1] != 0) play_pd = jkee + kkee + 1;
        }
    }
    counter = 0;
    plh = 0;
    jkee = 0;
    kkee = 0;
}
</code></pre>

<p>I get a segmentation fault when I try to run this code at the line : </p>

<pre><code>if(b-&gt;board[i + kkee + 1][jkee + kkee + 1] == 0 &amp;&amp; b-&gt;board[i + kkee][jkee + kkee + 1] != 0) play_pd = jkee + kkee + 1;
</code></pre>

<p>However in the exact above line I clearly state that if the numbers put in board are not in there, break.</p>

<p>(the board is defined in a struct like this: b->board[rows][columns])        </p>
