Click to See Complete Forum and Search --> : linked list problem


mps2
July 11th, 2002, 01:56 PM
Does anyone see a problem with the following code? Whenever I'm going through the 'for' loop in the Populate class, I get a runtime error. It says,"Debug Assertion Failed, File:dbgheap.c, Line: 1100". I'm using Microsoft Visual Studio.Net. I just can't figure out where i'm going wrong with this list. It builds about half of the lists and then I get said error.

If you need more info, let me know, I'll add to it.

struct Node{
unsigned int* data;
int id;
};

struct List{
List* next;
Node message;
};

class DataRead{
public:
List *Head;
Node DataReadIn;
void Populate();
void FillNode(Node&,int);
};


void DataRead::Populate()
{
int i=0;

List* current=new List;
while(i<10000)
{
if(Head->message.id==0)
{
current=Head;
current->message.data=new usint[36];
FillStruct(DataReadIn,i);
current->message=DataReadIn.data;
}
else
{
current->next=new List;
current=current->next;
current->messge.data=new usint[36];
FillStruct(DataReadIn,i);
current->message=DataReadIn.data;
current->next=NULL;
}
i++;
}

}

void DataRead::FillStruct(Node &dataNode, int nodeId)
{
usint *temp=new usint;
int i=0;

srand( (unsigned)time( NULL ) );

for(;i<36;i++)
temp[i]=0x0740 + rand();
dataNode.data=temp;
dataNode.id=nodeId;
}

jfaust
July 11th, 2002, 02:13 PM
grrrr.. Please don't post to multiple forums.

Jeff