I can't seem to figure this out. The multidimensional array "structure" changes its values without any reason.
I am using Visual Studio 2010 for debugging, and when it enters "structure[x][y] = readData" for the first time, it changes the array's value, but it changes back on next line. I don't understand why "mapFile.getline(readData, 10, ',')" alters the array "stucture".
By the way, the file that is being read (fName) is a txt-file containing "1,0,row,1,1,end".
void graphicsLoader::loadFromFile(std::string fName) {
//x and y position for tile
int x;
int y;
char readData [9] = "";
//structure[x][y]
char *structure[100][100];
//open file for reading
std::fstream mapFile(fName, std::fstream::in);
//read first entity from file
mapFile.getline(readData, 10, ',');
for (y = 1; y <= 100; y++){
for (x = 1; x <= 100; x++){
if (strcmp(readData, "row") == false || strcmp(readData, "end") == false){
//New row begins. Reset x pos. and advance y pos.
x = 0;
break;
}
structure[x][y] = readData;
mapFile.getline(readData, 10, ',');
}
mapFile.getline(readData, 10, ',');
}
mapFile.close();
}