title: Two Dimensional Char Arrays
body: <p>Recently when I am doing code in C, I need declare a two dimensional array as follows:</p>
  
  <pre><code>char foo[20][20];
  </code></pre>
  
  <p>Later I will assign character arrays in to the <code>foo</code>.</p>
  
  <p>After that I need to copy these strings into some other variables.</p>
  
  <p>Copying goes like this:</p>
  
  <pre><code>strcpy(date, foo[0]);
  strcpy(name, foo[1]);
  strcpy(des, foo[6]);
  strcpy(cpy, foo[2]);
  </code></pre>
  
  <p>Since I did not maintained the sequence while copying like <code>foo[0]</code>, <code>foo[1]</code>, <code>foo[6]</code> and <code>foo[2]</code>, I got some garbage to <code>p3</code> along with the original string.<br>
  Later I corrected the sequence to <code>foo[0]</code>, <code>foo[1]</code>, <code>foo[2]</code> and <code>foo[6]</code> in copying and I got the expected result.</p>
  
  <p>Please give clarity on this.</p>
  
  <p>Actually the pointers p1, p2, p3 and p4 are the variables in a structure.
  Structure goes likes:</p>
  
  <pre><code>struct sample
  {
      char date[9];
      char name[8];
      char des[8];
      char cpy[9];
  };
  </code></pre>