I'm writing code to read in a 7x15 block of text in a file that will represent a 'maze'.
#include <iostream>
#include <fstream>
#include <string>
#include "board.h"
int main()
{
char charBoard[7][15]; //the array we will use to scan the maze and modify it
ifstream loadMaze("maze"); //the fstream we will use to take in a maze
char temp; //our temperary holder of each char we read in
for(int i = 0;i < 7; i++)
{
for(int j = 0; j < 15; j++)
{
temp= loadMaze.get();
charBoard[i][j] = temp;
cout << charBoard[i][j]; //testing
}
cout << endl;
}
return 0;
}
this was my original draft but this didnt work as it kept returning ? for each char it read. This is the maze im testing with:
############# # ############ # # ######### #### # ! # ############
EDIT: The cout is printing this:
############# # ############ # # ######### #### # ! # #########
Am I not escaping \n's?
I've been coding for a few hours so I think its a simple mistake I'm not catching that's tripping me up right now. Thanks!