title: Draw a Sodoku Grid in C++
body: <p>So I have been writing a program that will take a sodoku from an external text file, fill it into a 2 dimensional array, and then print the solved result. I have all the logic for solving the program finished, but whenever I output the sodoku into the console, it looks like this:</p>
  <pre><code>8 1 2 7 5 3 6 4 9
  9 4 3 6 8 2 1 7 5
  6 7 5 4 9 1 2 8 3
  1 5 4 2 3 7 8 9 6
  3 6 9 8 4 5 7 2 1
  2 8 7 1 6 9 5 3 4
  5 2 1 9 7 4 3 6 8
  4 3 8 5 2 6 9 1 7
  7 9 6 3 1 8 4 5 2
  </code></pre>
  <p>Now if my goal was simply to output the result, this would be perfectly fine, but I want something more easy to read and Sodoku-like.</p>
  <p>Ideally I would like for their to be 3x3 squares around all of the necessary blocks in the Sodoku, and make it look something like this or at least something similar:</p>
  <pre><code> ----- ------ ------
  |8 1 2| 7 5 3| 6 4 9|
  |9 4 3| 6 8 2| 1 7 5|
  |6 7 5| 4 9 1| 2 8 3|
   ----- ------ ------
  |1 5 4| 2 3 7| 8 9 6|
  |3 6 9| 8 4 5| 7 2 1|
  |2 8 7| 1 6 9| 5 3 4|
   ----- ------ ------
  |5 2 1| 9 7 4| 3 6 8|
  |4 3 8| 5 2 6| 9 1 7|
  |7 9 6| 3 1 8| 4 5 2|
   ----- ------ ------
  
  </code></pre>
  <p>Here I will also include my print function for the sodoku itself:</p>
  <pre><code>void print_puzzle()
  {
      for (int i = 0; i &lt; 9; i++)
      {
          for (int j = 0; j &lt; 9; j++)
          {
              cout &lt;&lt; puzzle[i][j] &lt;&lt; &quot; &quot;;
          }
          cout &lt;&lt; endl;
      }
  }
  </code></pre>
  <p>If anyone could help me out with the specific implementation to achieve my goal that would be extremely helpful</p>
  <p><strong>EDIT</strong></p>
  <p>I have rewritten the print function of my code to where it outputs the sodoku as the following:</p>
  <pre><code> ------  ------  ------
  | 8 1 2 | 7 5 3 | 6 4 9 |
  | 9 4 3 | 6 8 2 | 1 7 5 |
  | 6 7 5 | 4 9 1 | 2 8 3 |
   ------  ------  ------
  | 1 5 4 | 2 3 7 | 8 9 6 |
  | 3 6 9 | 8 4 5 | 7 2 1 |
  | 2 8 7 | 1 6 9 | 5 3 4 |
   ------  ------  ------
  | 5 2 1 | 9 7 4 | 3 6 8 |
  | 4 3 8 | 5 2 6 | 9 1 7 |
  | 7 9 6 | 3 1 8 | 4 5 2 |
   ------  ------  ------
  </code></pre>
  <p>I have done so by editing my function to the following:</p>
  <pre><code>void printPuzzle()
  {
      for (int i = 0; i &lt; 9; i++)
      {
          if (i == 0 || i == 3 || i == 6)
          {
              cout &lt;&lt; &quot; ------  ------  ------&quot; &lt;&lt; endl;
          }
          for (int j = 0; j &lt; 9; j++)
          {
              if (j == 0 || j == 3 || j == 6)
              {
                  cout &lt;&lt; &quot;| &quot;;
              }
              cout &lt;&lt; puzzle[i][j] &lt;&lt; &quot; &quot;;
          }
          cout &lt;&lt; &quot;|&quot;;
          cout &lt;&lt; endl;
      }
      cout &lt;&lt; &quot; ------  ------  ------&quot; &lt;&lt; endl;
  }
  </code></pre>