the following is a part of my sprite loading function,
using vc++ .net 7

running in the debuger and running the debug exe it runs perfectly, running the release exe from the debuger runs perfectly but on running the release exe outside the debuger it crashes sumtimes not all the time after the log "Loaded sprite" and before the Archive is asigned,

all it could be is the fscanf or fgets i tried both thats y it looks messed up.

any help would be apreitiated.

p3p

Code:
	char tempfiledat[256],buffer[256];
	std::string filename,ofilename,Archive;
	int pause=0, r=0, g=0, b=0, w=0, h=0, x=0, y=0, Bx=0, By=0;
	FILE *fp;

	if(iniFile[0]=='.'){
		filename=parse("%s.ini", iniFile.c_str());
	}else{
		filename=parse("%s%s.ini", SPRITEDIR,iniFile.c_str());
	}
	
	Log(T_LOG,"Loading Sprite: \"%s\"", filename.c_str());

	if((fp=fopen(filename.c_str(), "r+")) == NULL){
		Log(T_ERROR,"opening file %s", filename.c_str());
		return -1;
	}
	//Log to see if crash is in file load
	Log(T_LOG,"Loaded Sprite: \"%s\"",filename.c_str());
	
	fscanf(fp, "BIN: %s", tempfiledat);
	fgets(buffer, 255, fp);
	Archive=parse(tempfiledat);

	fscanf(fp, "FILE: %s", tempfiledat);
	fgets(buffer, 255, fp);
	filename=parse(tempfiledat);
	
	fscanf(fp, "OVERLAY: %s", tempfiledat);
	fgets(buffer, 255, fp);
	ofilename=parse(tempfiledat);