title: What cause this array value to change?
body: <p>I am going slightly crazy over a value changing in a multidimensional array even though assignment doesn't appear to happen. I am working on a program to find the longest common subsequence between two strings. To that end, I create an array of arrays whose dimensions are the lengths of the respective strings. I initialize the first row and column of the array to zeroes, but for some reason <code>arr[2][0]</code> becomes <code>1</code>. This happens in the first iteration of the outer for loop when <code>j=0</code> and <code>k=5</code>. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;math.h&gt;
  using namespace std;
  
  int main(int argc, const char * argv[]) {
      // insert code here...
      string a = "bird";
      string b = "turdbi";
      int aLen = a.length();
      int bLen = b.length();
      int arr[aLen][bLen];
      //initializing the multidimensional array
      for (int i=0;i&lt;aLen;i++){
          arr[i][0]=0;
      }
      for (int i=0;i&lt;bLen;i++){
          arr[0][i]=0;
      }
      int subsequence=0;
      for (int j=0;j&lt;aLen;j++){ //(0,0) is the leftmost corner of the table, to compensate for additional row/col
          for(int k=0;k&lt;bLen;k++){
              if (a.at(j)==b.at(k)){
                  subsequence = arr[j][k]+1; //add one to upper diagonal
              }
              else {
                  subsequence = max(arr[j+1][k],arr[j][k+1]); //find max value from adjacent cells'
              }
              //how does arr[2][0] ==1??
              arr[j+1][k+1]=subsequence;
          }
          cout &lt;&lt; endl;
      }
  
      return 0;
  }
  </code></pre>