0

Hey I'm having trouble with a HW assignment, no need to give me the answer out right but any help would be appreciated!

I'm just trying to search a linked list and find a node then delete it. Here is what I have so far:

void deleteSong()
{
    char deleteMe[sz];
    bool found = false;
    Node* Scan = playList.GetFirstNode();
    Song* Check;
    cin.ignore();
    cout << "Enter the song path you would like to delete: ";
    cin.getline(deleteMe,sz);
    Check = new Song(deleteMe);



    if(Scan==0)
    {
        cout << "Nothing in list" << endl;
        return;
    }
    else
    {
        while(Scan!=0 && !found)
        {
            if(Scan->data_ == Check->GetSongName())
            {
                playList.RemoveThisLink(Scan);
                found = true;
                cout << "DELETED" << endl;
            }
            else
            {
                cout << "SCANNING" << endl;
                Scan = Scan->next_;
            }
        }
    }
}

The code compiles fine, it just doesn't find a hit at this if statement: if(Scan->data_ == Check->GetSongName())

Please tell me if you would like me to supply anymore code.

2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by JamesCherrill
0

That looks like C or one of its derivatives. This is the Java forum. Please decide what language you are using and post this in the appropriate forum.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.