I wrote a level load function that worked fine in debug, but when I tried to make a release exe it crashes. I've tracked the problem to the opening of the file.
here is the code, given a level number it will open a file in the Level folder
FILE * pFile;
char filename[] = "Levels/level"; //first part
char num[2];
wsprintf(num, "%d", level); //level num
strcat(filename, num); //add # to level
strcat(filename, ".dat"); //add .dat to level
if( (pFile = fopen (filename,"r")) != NULL)
return pFile;
This should open a file named "level1.dat" for example
I replaced the string concatenating code with
char filename[] = "Levels/level1.dat";
and it works fine, so I believe the problem is in putting the string together.
btw the function returns a file pointer so another function can read in data.
I'm not sure why it works in debug, but not release.
The error I get when trying to run the program us
"Exception privileged instruction
(0x0000096) at 0x00400080"
any ideas?