title: C++: Reading from a file with get(); not working as intended
body: <p>Let's say I have a file that looks like the following:</p>
  
  <pre><code>|----------------------------------------------|
  |                                              |
  | |---------|       |--------------|           |
  | |.........|       |..............|           |
  | |.........|       |..............|           |
  | |----+----|       |----+---------|           |
  |      #                 #                     |
  |      ###################                     |
  |                                              |
  |----------------------------------------------|
  </code></pre>
  
  <p>(it will be a map file for a game)<br>
  In this case, <code>MAX_WIDTH</code> is 48 and <code>MAX_HEIGHT</code> is 10.</p>
  
  <p>I made it so that it does not skip whitespace when reading with<br>
  <code>infile.unsetf(ios_base::skipws);</code></p>
  
  <p>Then I used <code>get()</code> in a loop like following:</p>
  
  <pre><code>char tile[MAX_HEIGHT][MAX_WIDTH];
  char c;
  
  for(int i=0; i&lt;MAX_HEIGHT; i++) {
      for(int j=0; j&lt;MAX_WIDTH + 1; j++) {
          infile.get(c);
          if(c == '\n') {
              continue;
          }
          tile[i][j] = c;
      }
  }
  </code></pre>
  
  <p>But then after each line, it looked like lines were being pushed when I printed the array.</p>
  
  <pre><code>|--------------------------------------------|
  |
  || |--------|      |-------------|
  || |........|      |.............|
   || |........|      |.............|
    || |----+---|      |----+--------|
  </code></pre>
  
  <p>Not exact but something like this.</p>
  
  <p>What could've gone wrong and what can I do about it?</p>
  
  <p>(+) Printing the array goes like the following:</p>
  
  <pre><code>for(int i=0; y&lt;MAX_HEIGHT; y++) {
      for(int j=0; x&lt;MAX_WIDTH; x++) {
          cout &lt;&lt; tile[y][x];
      }
      cout &lt;&lt; endl;
  }
  </code></pre>