Skip to main content
gamedev.net
🔒 Locked

Assert with new operator?

Started by ms291052 Jan 20, 2004 at 5:19 PM 2 replies 200+ views
Original Post
ms291052
ms291052
I recently wrote a program that loaded the .3do file type (it''s a 3D file format). It worked just fine, and then I tried to turn it into a class and it''s now giving me this: Screenshot The problem always occurs here:
vector<string*>      lines;
ifstream file(filename);
	while(!file.eof())
	{
		char* temp = new char[999]; //This Line causes the error

		file.getline(temp, 999);
		if(temp[0] == ''#'')
		{
			goto end;
		}
		lines.push_back(new string(temp));
		NumLines++;
		end:
		delete[] temp;
	}
This code read the file and puts it into a vector of strings, as well as removing comments (lines that start with a #) when I run in debug mode. And in normal mode the program crashes if I hit retry on that dialog box. Any ideas as to why?
SiCrane
SiCrane
The actual problem is probably somewhere else. The assert signals a heap corruption condition. Probably the error occurs somewhere between the last new call and this new call, most likely due to a bad deletion of some sort.
superpig
superpig
[Moved to: General Programming]
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.