Hi, so I'm working on a class project where the user can create up to 5 playlists by choosing songs from a master list.
Each playlist is going to be it's own linked-list. How do I correctly make an array of linked-lists? I thought I did it right, but my program keeps crashing when I try to assign the values from the master list to the first linked-list in the array
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
struct Music_Info {
string Song_Name;
string Artist;
int Ranking;
int Release_Year;
int Decade;
char Performer_Type;
string Genre;
Music_Info *nextaddr;
};
// So each playlist is getting the struct Music_Info
Music_Info *Playlist[5];
int PLCnt = 1; // This is used to keep track which playlist we're working on
Playlist[PLCnt]->Song_Name = current_song->Song_Name; // Current_Song is the master linked-list. My program keeps crashing here so I think I made the array of linked-lists incorrect
This creates an array of pointers. Each of those pointers is NOT pointing at a Music_Info object. This is because you haven't made any Music_Info objects. Each of those pointers is pointing into random memory somewhere, so when you try to write to that random memory, things go very wrong.
You need to create Music_Info objects for these pointers to point at.