Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Linked List Question

  • 03-05-2004 05:47PM
    #1
    Closed Accounts Posts: 2,039 ✭✭✭


    I searched the forum for Linked lists and got some results but they didn't really help much so here goes.

    I'm doing a college project and I'm almost finished but I've run into a problem. The task is to maintain a doubly linked list of names. The program breaks when I try to insert an item or delete an item. From what I can tell it's the srtcmp bit in the insert and erase procedures thats causing the problem I just don't know how to fix it. Any help would be really appreciated.

    The code I have so far is in the attached file. It's in a text file so you'll have to resave it as a .cpp file.


    Cheers
    Rory


Comments

  • Registered Users, Registered Users 2, Paid Member Posts: 2,032 ✭✭✭lynchie


    while(curr != NULL || strcmp(curr->Name,arr)

    You are using an || statement. curr can be null on the left side of the condition and when it goes to evaluate the right side of the condition curr->Name will be null. This is causing your error. Didnt look over the code in detail but maybe you need to use and && statement instead?


Advertisement