I'm trying to read text from a file into a char's matrix
I do it this way:
char** crearMundo()
{
ifstream input("C:\\Users\\JhonAlx\\Desktop\\file.txt");
input >> filas;
input >> columnas;
filas += 2;
columnas += 2;
char** laberinto = crearMatriz(filas, columnas);
//Initial fill
for(int i = 0; i < filas; i++)
{
for(int j = 0; j < columnas; j++)
{
laberinto[i][j] = ' ';
}
}
//Next two loops will fill only borders
for(int i = 0; i < filas; i++)
{
laberinto[0][i] = '?';
laberinto[filas - 1][i] = '?';
}
for(int i = 0; i < columnas; i++)
{
laberinto[i][0] = '?'; //VS throws error in this line
laberinto[i][columnas - 1] = '?';
}
//Fill actual content of file, omitting borders
for(int i = 1; i < filas - 1; i++)
{
for(int j = 1; j < columnas - 1; j++)
{
input >> laberinto[i][j];
}
}
return laberinto;
}
This morning when I programmed it, it was fine, but now it throws this error:
Access violation reading location 0xFDFDFDFD
Debugging with VS2012 and looking with Locals explorer, I get this text on the ifstream variable:
input{_Filebuffer={_Set_eback=0xcccccccc < Error reading characters of string.> _Set_egptr=0xcccccccc < Error reading characters of string.> ...} } std::basic_ifstream >
Any help will be apreciated.