CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2000
    Posts
    110

    linked list problem

    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, Filebgheap.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;
    }

  2. #2
    Join Date
    Mar 2002
    Location
    California
    Posts
    1,582
    grrrr.. Please don't post to multiple forums.

    Jeff

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured