Hi guys, I pretty new to c++ and I have a problem with getline. I am supposed to call in a text file into a 2d character array and the text file is a maze. Here is my code:
void maze::open()
{
ifstream file;
int row=0;
file.open("standard.txt");
while (!file.eof())
{
getline(file, store);
for ( int col = 0 ; col < store.size() ; col++ )
{
Maze[row][col] = store[col];//store is a string variable
}
row++;
}
file.close();
}
void maze::printmaze()
{
for(int i=0;i<50;i++)
{
for(int j=0;j<20;j++)
{
cout<<Maze[i][j];
}
}
cout<<endl;
}
I have been getting weird outputs and I tried searching through this forum for similiar problems but i didn't find any. Please help me.