Hello
I am trying to read from a file. I'm followed a tutorial and had it working perfectly before, and it still does now..
But the problem is that one variable that I'm reading from the file is causing my program to crash.
All the other vars I'm reading, are fine. And I know its the one variable cause I pinpointed it out. Commented it out, the program runs fine. With it, crash.
The crash is a simple "The program has stop responding..." then closes.
The other problem is that this value is important to read, as without it there's no point in making the program :D
Ok the variable, is a simple integer, something like 208. (Remember that)
But all the values from the file are ints too.
And some are much larger then the one above, and load fine. As well as display fine when displayed.
The other strange problem with this is if its a value of 8< its fine. Displays, works etc..
But..I need values < 100...and why anything after 8 causes it to crash is beyond me.oo
Also adding more values to read results in nothing. Still reads.
Moving where it reads this int still causes crash.
Renaming the variable it stores to still a crash.
So now I am just out of ideas on what to do, cause its not only looks right, doesn't trigger any of the errors or custom exits. And is exactly the same way as the old program and tutorial, just with more values being read.
Oh and another strange thing about this, and how I knew it was 8< cause I had a string at the beginning of the file.
And I did getline etc.. and after that came the value 208.
It worked....except that it cut the 200 and left it with 8........................
Its like the program doesn't like the 208 or just plain that variable...
Heres an example:
bool Load(int Level) {
if (Level == 0 || Level >= 21) { return false; }
char buffer[200];
sprintf(buffer, "Resources/%d.ini", Level);
ifstream load;
load.open(buffer);
if (load != NULL) {
load >> M;
load.ignore();
load >> T;
load.ignore();
load >> W;
load.ignore();
load >> H;
load.ignore();
load >> Start;
load.ignore();
load >> Startx;
load.ignore();
//load >> E; //This is whats crashing it....unless its 8
//load.ignore();
load.close();
} else { return false; }
return true;
}
And example ini file:
1
200
1280
1000
100
800
208
0
Sorry for such a long post.
Such a simple problem completely stops this program and causing me to pull my hair out!
And like I said it worked, works, and should cause its just that one variable thats the same as the others that doesn't like me for some reason.
[searching=]http://www.daniweb.com/forums/thread68731.html[/searching]
Somewhat similar to mine except I'm dealing with variables.
Thanks
-Bill