okay, heres an update. I messed around a bit and discovered that if I attempt to open menu.dat again (after the first time i open it), the game crashes. however, if i open any other file(s), in any prder, back and forth, open them twice, open them eight times in a row, it works. but menu.dat only works once.
???
hmm weird
here's the current code(43 lines right now and absolutely barebones :);
Code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string dat[10], currentfile("menu.dat");
char* buffer = "";
char ch, input = ' ';
int chtoint; //just giving things values
ifstream thisdat;
for(;;) {
thisdat.open(currentfile.c_str());
cout << "Opened " << currentfile.c_str() << endl;//for debugging
for(;;) {
thisdat.get(ch);
if (ch == '<') break;
cout << ch;
}
if (ch == '<') {
thisdat.get(buffer, 300, '>');
dat[1] = buffer;
}
buffer = "";
thisdat.close();
cout << "\nChoice: ";
cin.get(input);
cin.get();
switch (input) {
case '1':
chtoint = input - 48; //0-9 are 48-57 in ascii code, we want them to be 0-9
currentfile = dat[chtoint];
break;
default:
break;
}
}
return 1;
}
heres menu.dat:
Code:
Here's choices:
1. goto A<a.dat>
a.dat:
Code:
We're in A
1. goto B<b.dat>
b.dat:
Code:
We're in B
1. goto menu<menu.dat>
when the prog executes, it reads out all of menu.dat (except whats in the angle brackets, which goes into dat[1]);
i pick choice 1
it enters a.dat
i pick choice 1 again
it enters b.dat
i pick choice 1 again
it exits with an invalid page fault
any ideas on why i cant go back to menu.dat????