title: Access violation writing location... Where is the bug? (Veitch diagram)
body: <p><strong>NOTE: I had two variables with the same name... Big thanks to Stefan Birladeanu  and Henrik for noticing that!*</strong></p>
  
  <p>Recently I started writing code that helps me input the values of bool function to Veitch (Karnaugh) diagram with 4 variables. The code should write elements to matrix size 4x4 but with these indexes:</p>
  
  <ol>
  <li>element - index 3,3</li>
  <li>element - index 2,3</li>
  <li>element - index 3,2</li>
  <li>element - index 2,2</li>
  <li>element - index 0,3</li>
  <li>element - index 1,3</li>
  <li>element - index 0,2</li>
  <li>element - index 1,2</li>
  <li>element - index 3,0</li>
  <li>element - index 2,0</li>
  <li>element - index 3,1</li>
  <li>element - index 2,1</li>
  <li>element - index 0,0</li>
  <li>element - index 1,0</li>
  <li>element - index 0,1</li>
  <li><p>element - index 1,1
  This is the code of main():</p>
  
  <pre><code>    void main()
      {
          int n;
  
      n=4;
  
      int **VeitchDiagram;
  
      //allocate memory for Veitch diagram
      VeitchDiagram = new int *[n];
      for(int i=0; i&lt;n; i++)
          VeitchDiagram[i]=new int [n];
  
      //enter the elements
      for(int i=0; i&lt;n; i++)
      {
          int j, k;
          if(i%2==1)
          {
              k=0;
              if(i&lt;2)
                  j=4;
              else
                  j=-1;
              for(int k=0; k&lt;2; k++)
              {
                  if(i&lt;2)
                      j--;
                  else
                      j++;
                  cin &gt;&gt; VeitchDiagram[k][j];     //this part writes the input to elements with index (at least it should do that):
                  k++;                            //0,3     1,3     0,2     1,2     if i%2==1 and i&lt;2
                  cin &gt;&gt; VeitchDiagram[k][j];     //0,0     1,0     0,1     1,1     if i%2==1 and i&gt;=2
                  k--;
              }
          }
          else
          {
              k=3;
              if(i&lt;2)
                  j=4;
              else
                  j=-1;
              for(int k=0; k&lt;2; k++)
              {
                  if(i&lt;2)
                      j--;
                  else
                      j++;
                  cin &gt;&gt; VeitchDiagram[k][j];     //this part writes the input to elements with index (at least it should do that):
                  k--;                            //3,3     2,3     3,2     2,2    if i%2==0 and i&lt;2
                  cin &gt;&gt; VeitchDiagram[k][j];     //3,0     2,0     3,1     2,1    if i%2==0 and i&gt;=2
                  k++;
              }
          }
      }
  
      //free memory allocated for VeitchDiagram
      for(int i=0; i&lt;n; i++)
          delete [] VeitchDiagram[i];
      delete [] VeitchDiagram;
  }
  </code></pre></li>
  </ol>