I've never seen this before and am perplexed beyond belief... by the way I'm using Visual Studio

I have a rather large program/game i'm working on right now, and it reads in via ifstream file i/o from binary files in several locations to initialize variables. For some reason for one set of files to read in it is opening and reading the wrong files, but only in release mode. Debug mode works like a charm, but in release it just won't work right. I'm getting strings longer than 4 bytes thrown into my ints and bunk values into others.

bool	CParticleEffect::LoadEffect(char* fileName)
{
	ifstream file;
	file.open(fileName,ios_base::in | ios_base::binary);

	if(!file.is_open())
	{
		ofstream problem;
		problem.open("particle_problem.txt", ios_base::out | ios_base::trunc);
		problem.write(fileName, sizeof(fileName));
		return false;
	}

i have that check at the begining to make sure the file is opening and it says that it is

has anyone seen or heard anything like this before... if so throw out a tip or give me a direction to look in... please. It would be greatly appreciated

Thanks

I didn't look too closely, but this sticks out.

problem.write(fileName, sizeof(fileName));

Wouldn't you want the length of the string rather than the size of a pointer?

yeah, but that is neither here nor there...

file.open(fileName, ios_base::in | ios_base::binary);

this is not opening the correct file for whatever reason... i just tossed that check in right before i posted here to see if it got past the is_open check(which it does)...

i'm just curious if anyone has had a problem similar to mine

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.