title: Printing a 2D char array in C++
body: <p>so I have a problem with my code which I can't pinpoint. Simply put, I want to print out the contents of a 2D char array in c++ in a grid format. My code is the following (keep in mind that I dont want to change the structure of my code just find why I am not getting the desired result):</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  void drawBoard(char board[3][4])
  {
      int j = 0;
  
      for (int i = 1; i &lt; 12; i++)
      {
          if ((i % 4) == 1 || (i % 4) == 2)
          {
              cout &lt;&lt; " " &lt;&lt; board[i][j] &lt;&lt; " |";
          }
          else if ((i % 4 == 3))
          {
              cout &lt;&lt;  " " + board[i][j] &lt;&lt; endl;
          }
          else
          {
              cout &lt;&lt; "---+---+---" &lt;&lt; endl;
              j += 1;
          }
      }
  }
  
  int main()
  {
      char board[3][4] = { {' ', ' ', ' ', '\0'}, {' ', ' ', ' ', '\0'}, {' ', 
      ' ', ' ', '\0'} };
      drawBoard(board);
  
      cin.get();
  }
  </code></pre>
  
  <p>What I would expect for this to give me is a basic tic-tac-toe grid with blank spaces where the X's and O's go. Instead what I get is a grid as expected with random characters placed in some of the squares and no matter how much tweaking I do gives the same or a similar result but I don't understand why. Any help would be appreciated (Also preferably not including anything beyond basic c++ like functions, loops etc since I haven't learnt those yet and we can't use them in our assignment even if we know them).</p>