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

    C++ access violation exception?

    Hi all

    For the following code I keep getting an access violation exception but i'am not sure why. the expection seems to disappear when the size of the queue is one. queue being a single linked list:

    {
    b=H_queue_empty_H;
    H_queue_empty_H=H_queue_empty_H->next; // THE EXCECPION APPEARS HERE
    b->start=currentTime;
    b->duration= currentTime +GenExpRV(mewHwait_H);
    if(H_queue_tail_H!=(queue *)NULL)
    {
    H_queue_tail_H->next=b;
    b->prev=H_queue_tail_H;
    b->next = (queue *)NULL;
    H_queue_tail_H=b;
    }


    So guys what do you think might be the problem?

    Any suggestions plz

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: C++ access violation exception?

    H_queue_empty_H is null or invalid.

  3. #3
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: C++ access violation exception?

    How to use the debugger.

  4. #4
    Join Date
    Aug 2011
    Posts
    2

    Re: C++ access violation exception?

    It turned out that the linked list was not intialized properly
    The main error is this line:

    H_queue_H[max_QH_H-i-1].next=(struct queue *) NULL;

    When I exit for loop, I was setting first element's next field to NULL while I should have set the last one instead!

    Thanks guys

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