title: How to handle segmentation fault: 11 c++ osx
body: <p>I'm a beginner in programming, and I've come across an error for which I can't find explanation. I have searched thoroughly for a solution, I see many people get this problem, but I haven't been able to fix it.</p>
  
  <p>My program is just about creating a double-type matrix which I fill with two nested loops. After I compile it I get the .exe file, but when I run it the terminal says segmentation fault: 11 logout.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;math.h&gt;
  #include &lt;cstdlib&gt;
  int main()
  {
          long N,NN = 0;
          double h, tau, T1, T2 = 0; 
          N=100;
          NN=pow(N,3);
          h=1/N;
          tau=pow(1/N,3);
          T1=1;
          T2=1.5;
          double T [N][NN];
  
           for (int i=0; i&lt;N; i++) {              
                   T [i][0]=T1;
                   for (int j=0; j&lt;NN; j++) {
                         T [0][j]=T1;
                         T [N][j]=T2;}}
  
          for (int i=1; i&lt;N-1; i++) {
                  for (int j=1; j&lt;NN; j++) {
                        T [i][j]=T [i][j-1]+(tau/(pow(h,2)))*(T [i+1][j-1]+T [i-1][j-1]-2*T [i][j-1]);}}
  
  
  return 0;
  }
  </code></pre>
  
  <p>Does anyone know what the problem is? Setting lower N does not help. I think this is a very basic program, sorry to bother you all, thank you!</p>