I have a nice save function, except for a minor (well major) problem. There are no errors at compile or anything like that. But when I run the program and it gets to a certain line of code I get a windows error that says "blah.exe has encountered an error and must be closed. Sorry for any inconvenience.......". You know the rest. I have windows xp. This happened once before when I didnt initialize a variable, i think. Anyhow, there is nothing like that that could cause a problem. I've zeroed in on the lines where the windows error pops up:
ofstream save("player.txt")
save>>current_room->id>>"\n";
save>>current_weapon->id>>"\n";
there are 3 others. this is in main:
...so current_room points to another variable of type room, which has an element that points to another variable of type room. this isnt the exact code, but its just about exact. i pass current_room to my saving function. when i do save>>current_room->id;, i get the windows error. It also happens with other variables that point to something. i've even tried saying something like:Code:struct ROOM { ROOM* north; ROOM* south; ROOM* east; ROOM* west; int id; }; ROOM chamber; ROOM hallway; chamber.north=&hallway; chamber.id=1; ROOM* current_room; current_room=&chamber.north;
int id=current_room->id;
and using 'id' instead of 'current_room->id'.that doesnt even work and it is a regular integer! i know that i can use current_room and things that it points to in functions because there are many others that do. this just makes no sense at all to me. when i get home i'll post the exact code, but i've pretty much explained it all. It makes no sense! help!