I'm trying to read a .txt file that uses 21 characters (image below). However when it is read and output, an extra x is present in the bottom right corner and the length of the string used to store it is 24 instead of 21. I feel like this is an obvious error but I couldn't find anything.
void readMaze(string fileName)
{
ifstream input(fileName);
string stringarray;
char data;
while (!input.eof()) //While loop used to store each individual character to the string.
{
input.get(data);
stringarray += data;
}
cout << "The Maze being solved is: " << endl;
cout << stringarray << endl; // Outputs the maze to the user
convertMaze(stringarray); //The maze is then converted to binary in this function.
input.close();
}
Text file being read:
xxxxxxx
xA...Bx
xxxxxxx
Output:
xxxxxxx
xA...Bx
xxxxxxxx