title: How to populate a sudoku (9x9) grid in ncurses?
body: <p>I have a 9x9 sudoku grid that I've drawn using ncurses' (mvw)hline/vline functions and I'm now trying to populate it using numbers from a 9x9 array. My question is what is the most effective/efficient way to do this?</p>
  
  <p>If it's helpful, I'm using ncurses v6.1-r2 and C++17 (compiled with g++). I've gotten about as far as looping through the array (from which the board will be populated), but after that I can't think of a way to populate each square.</p>
  
  <p>Here is the code I'm using to draw the grid.</p>
  
  <pre class="lang-c prettyprint-override"><code>WINDOW *create_board(int x, int y, int width, int height) {
      WINDOW *local_win;
  
      local_win = newwin(height, width, y, x);
  
      mvwaddch(local_win, 0,          0,         '+');
      mvwaddch(local_win, 0,          width - 1, '+');
      mvwaddch(local_win, height - 1, 0,         '+');
      mvwaddch(local_win, height - 1, width - 1, '+');
  
      mvwhline(local_win, 0,          1, '-', width - 2);
      mvwhline(local_win, height - 1, 1, '-', width - 2);
  
      mvwvline(local_win, 1,      0,         '|', height - 2);
      mvwvline(local_win, 1,      width - 1,     '|', height - 2);
  
      for (int i = 0; i &lt; 9; i++) {
          mvwvline(local_win, 1,          (10 * i), '|', height - 2);
          mvwhline(local_win, (4.2 * i),  1,        '-', width - 2);
      }
  
      wrefresh(local_win);
      return local_win; 
  }
  </code></pre>
  
  <p>I apologize if the wording is awkward, English is not my first language.</p>
  
  <p>EDIT: for clarity, I do not want to <em>generate</em> a sudoku board, I simply want to populate an existing grid with predefined numbers in an array.
  For example:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>int board[9][9] =  
     {{0,0,0,7,0,0,0,0,0},
      {1,0,0,0,0,0,0,0,0},
      {0,0,0,4,3,0,2,0,0},
      {0,0,0,0,0,0,0,6,0},
      {0,0,5,0,9,0,0,0,0},
      {0,0,0,0,0,4,1,8,0},
      {0,0,0,8,1,0,0,0,0},
      {0,2,0,0,0,0,5,0,0},
      {4,0,0,0,0,3,0,0,0}};
  </code></pre>