Segfault in Cygwin but not VS, any ideas?
<p>It works with Visual Studio, but segfaults in Cygwin, which is weird because I'm compiling the same source, and both generate a Windows executable. GDB doesn't work very well for me in Cygwin for some reason, and the error doesn't appear in VS so I can't really debug it there.</p>

<p>Any ideas?</p>

<pre><code>int main(void)
{
    Pair ***occurences = new Pair**[20];

    int i, j, k;
    for (i = 0; i &lt; 20; i++)
    {
        occurences[i] = new Pair*[i+1];

        for (j = 0; j &lt; i+1; j++)
        {
            occurences[i][j] = new Pair[26];

            for (k = 0; k &lt; 26; k++)
            {
                Pair pair;
                pair.c = k + 'a';
                pair.occurs = 0;
                occurences[i][j][k] = pair;
            }
        }
    }

    std::fstream sin;
    sin.open("dictionary.txt");
    std::string word;

    while (std::getline(sin, word))
    {
        if (word.size() &lt; 21)
        {
            for (i = 0; i &lt; word.size(); i++)
            {
                // SEGFAULTING HERE
                occurences[word.size()-1][i][word[i] - 'a'].occurences++;
            }
        }
    }

    for (i = 0; i &lt; 20; i++)
    {
        for (j = 0; j &lt; i+1; j++)
        {
            delete [] occurences[i][j];
        }
        delete [] occurences[i];
    }
    delete [] occurences;

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