title: C how to move through 2 dimensional array based on address
body: <p>I'm trying to figure out how to loop through a 2 dimensional array as a single dimensional array.  Since a 2 dimensional array will occupy continuous memory, is there a way to address the two dimensional array as a single dimensional array by changing the index by 4 bytes.  I'm assuming an integer array.  Could some one provide an example?  I tried the following but it doesn't work:</p>
  
  <pre><code>for (int i = 0; i &lt; 2; i++){
      for (int j = 0;j &lt; 2; j++){
          z[i][j] = count;
          count++;
      }
  }
  
  for (int i = 0; i &lt; 4; i++)
      printf("%d\n", z[i]);
  </code></pre>