Mmmm, strange going-ons with my game.
First of all, I have to make an array of a custom class called "Room" of a size that's inputted from a file. So, what I did, is I made a pointer of type Room, and then I later made an array of Rooms, and linked the pointer to the array (sorry, don't know the proper terminology).
Problem is, the program compiles, but anytime I try and do anything with the array, like get a string from a spot, I get either 3 million+ for an integer, or gibberish text for a string, which ends with Windows2k saying my program's crashed and an error log has been created (wierd pointer-related problem).
So, here's my code--if anyone knows the solution, please let me know.
Code:
:::Driver.cpp:::
Room* roomListPtr;
// rest is omitted
::loadMap()::
int numRooms;
//some omissions
ifstream mapData("D:\\ashiq\\C++\\game\\data\\testMap.txt");
mapData >> numRooms;
Room roomList[numRooms+1];
roomListPtr = roomList;
// Data loading omitted
::movePlayer()::
//omitted; but this line is there
player.setRoom(roomListPtr[curRoom].getNorth());
I checked all my array sizes, verified my streams were created, did everything I could think of...it compiles....but outputting anything accessed from the roomListPtr causes crashness instantly.
--Ashiq