title: C++ how make a 2D array using strings and spaces instead of ints
body: <p>I am making a Sudoku program and my i have a test.txt file that reads </p>
  
  <pre><code>53__7____    
  6__195___
  _98____6_
  8___6___3
  4__8_3__1
  7___2___6
  _6____28_
  ___419__5
  ____8__79
  </code></pre>
  
  <p>where the "_" are actually spaces. The reason i give you _ is so you can see that there are literally only 9 characters on each line. </p>
  
  <p>I was thinking that I would have to do something like having GRID[row][column], however I frankly don't know what types I should put my arrays as and I am just lost.</p>
  
  <p>I simply want to make it so when i want to output say GRID[0][0] it returns 5, while if i ask for GRID[0][3] it returns a ' '. </p>
  
  <p>It is getting it so the array store both the numbers and the spaces is where i am getting completely lost </p>
  
  <p>What I currently have tried so far:</p>
  
  <pre><code>int main()
  {
   ifstream myfile(test.txt);
   string line;
   char sudoku_grid[9][9];
  
   if (myfile.is_open())
   {
    while(myfile.good())
     {
      getline(myfile, line);
      cout &lt;&lt; sudoku_grid[line] &lt;&lt; endl;
     }
     myfile.close();
    }
   else cout &lt;&lt; "error";
   return 0;
  }
  </code></pre>
  
  <p>it returns the error line 12: no match for 'operator [ ]' in 'sudoku_grid[line]'</p>
  
  <p>Here is my attempt though guidelines through you guys:</p>
  
  <pre><code>int main()
  {
   ifstream myfile(test.txt);
   string line;
   char sudoku_grid[9][9];
  
   if (myfile.good())
   {
    for(int i = 0; i &lt; 9; i++)
     {
      getline(myfile, line);
      for(int j = 0; j &lt; 9; j++)
         {
         if (line[j] == ' ')
            sudoku_grid[j][i] = -1;
         else  sudoku_grid[j][i] = line[i];
         }
      cout &lt;&lt; sudoku_grid[i] &lt;&lt; endl;
     }
     myfile.close();
    }
   else cout &lt;&lt; "error";
   return 0;
  }
  </code></pre>
  
  <p>The result is a very awkward answer of strange letters and a new numbers. </p>