I am to write a simple game that reads a labyrinth from a txt file and there are some issues concerning the conversion from the string to array of chars. The program does not copy the string into chars-it shows some strange symbols instead. The file is just a matrix 4 on 5 filled with "X" for the sake of simplicity.
So firstly I read the file and assign the string to a string array, and then I divided it using the c_str function, but sadly it doesn't work. I really don't know what to do and I appreciate any help I can get.
std::ifstream file( "labyrinth.txt" ) ;
std::string line ;
while( std::getline( file, line ) ) // as long as we succeed in reading a line
{
// use information in the line that was read
}
int i=0;
while(getline( file, line ) )
{
tab[i]=line;
i++;
}
but I still the array doesn't resemble the file. I haven't mentioned it, but I have something like "Cannot find or open the PDB file" several times in the debug output.
*****
problem solved-the cause was the wrong encoding, so thank you ;)