title: How can I use a pointer to a 2d char array?
body: <p>I am trying to use a pointer (*test) with a 2d char array (a[][]). But I can not seem to figure out what is the proper way to do it. I managed to get it working with an int array and int pointer, but the same solution did not work when I changed to char. I assume I was just lucky with ints, and did not really have a proper solution. I want to use pointer arithmetic to iterate as you can see in the code. My current output from this is gibberish.</p>
  
  <pre><code>char a[WIDTH][HEIGHT] = { {'a','b'},{'c','d'},{'e','f'} };
  
  char *test = (char *)a[0][0];
  
  int x,y;
  
  for (x = 0; x &lt; WIDTH; x++)
    {
      for (y = 0; y &lt; HEIGHT; y++)
      {
        printf("%c", test);
        test = test + 1;
      }
      printf("\n");
    }
  </code></pre>