title: Printing a 2D character array read in from a file
body: <p>Currently working on a school project involving a 2D char array representing a top-down view of a room, where 'W' = walls, 'F' = furniture, and ' ' = free space.  The array is meant to be read in from a file (contents of the file are below).</p>
  
  <p>FILE:</p>
  
  <pre><code>2                                   
  W   W   W   W   W   W   W   W   W   W
  W       F       F   F               W
  W       F       F   F       F   F   W
  W       F       F   F       F   F   W
  W       F       F   F       F   F   W
  W       F       F   F       F   F   W
  W       F       F   F       F   F   W
  W       F       F   F       F   F   W
  W       F                   F   F   W
  W       F                   F   F   W
  W           F               F   F   W
  W   F       F               F   F   W
  W   F       F               F   F   W
  W                           F   F   W
  W   W   W   W   W   W   W   W   W   W
  
  
  
  W   W   W   W   W   W   W   W   W   W
  W   F   F   F   F   F       F       W
  W   F   F   F   F   F       F       W
  W   F   F   F   F   F       F       W
  W   F   F   F       F       F       W
  W   F   F   F       F       F       W
  W   F   F   F       F       F       W
  W                   F               W
  W                   F       F       W  
  W   F   F   F               F       W
  W   F   F   F   F           F       W
  W   F   F   F   F           F       W
  W   F   F   F   F   F       F       W
  W   F   F   F   F   F       F       W
  W   W   W   F   W   W   W   W   W   W
  </code></pre>
  
  <p>The '2' is irrelevant for now - it represents the number of room configurations.  I know that I will have to make a loop with that number later in the project.</p>
  
  <p>Before I even begin the project, though, I wanted to print out my input to be sure that I am correctly reading in the file.  No matter what I try, I cant seem to get the correct configuration.  I have tried >> skipws as well as file.get() at multiple points in my code, and using these gives me different outputs but none match the original file. </p>
  
  <p>My current code:</p>
  
  <pre><code>    int main()
  {
      //Variables
      int i;
      int j;
      char room_array[room_height][room_width];
      char piece_of_room;
      int num_of_room_configurations;
  
  //Create File, Open File, and Check File
  ifstream room_file;
  room_file.open("C:\\(path)\\rooms.txt"); 
  if (room_file.fail())
      {
          cout &lt;&lt; "Could not open file." &lt;&lt; endl;
          system("pause");
          return 0;
      }
  
  //Loop Control / Use File; The Number of Room Configs (will need to put this in a loop later)
  room_file &gt;&gt; num_of_room_configurations;
  cout &lt;&lt; "Number of different room layouts: " &lt;&lt; num_of_room_configurations &lt;&lt; endl &lt;&lt; endl;
  
  //Create Room Array / Use File
  for (i = 0; i &lt; room_height; i++) //moves through rows
  {
      cout &lt;&lt; endl;
      for (j = 0; j &lt; room_width; j++) //moves through columns
      {
          room_file &gt;&gt; piece_of_room; //reading in values from file
          room_array[i][j] = piece_of_room; 
      }
  }
  
  //Echo Original Room Layout
  cout &lt;&lt; endl &lt;&lt; "ORIGINAL ARRAY:" &lt;&lt; endl;
  for (i = 0; i &lt; room_height; i++) //moves through rows
  {
      cout &lt;&lt; endl;
      for (j = 0; j &lt; room_width; j++) //moves through columns
      {
          cout &lt;&lt; room_array[i][j]; //formatting
      }
  }
  cout &lt;&lt; endl &lt;&lt; endl;
  
  system("pause");
      return 0;
  </code></pre>
  
  <p>I've taken out my attempts at including white spaces to make the code less complicated, so with this specific code I get this as an output:</p>
  
  <p><a href="https://i.stack.imgur.com/HncB0.png" rel="nofollow noreferrer">link to output screencap</a></p>
  
  <p>Apologies for such a long question but I wanted to be sure I didn't leave out anything that could assist in somebody helping me.  I do not have a good understanding of C++ by any means so it is more than possible that I's missing something very basic.  Any help at all would be very appreciated, thank you in advance.</p>
  
  <p>Also, this is my first post - if I've done anything incorrectly please let me know and I'll edit this if possible.</p>