I assume that you mean
artist1 cdname1
3
1:00 song1_1
2:00 song1_2
3:00 song1_3
artist1 cdname2
4
1:30 song2_1
2:00 song2_2
2:10 song2_3
2:20 song2_4
artist2 cdname1
2
3:00 song3_1
3:03 song3_2
You get all the artist1 CD's together, followed by all artist2 CD's etc, otherwise this gets more complicated.
> fscanf(inptr, "%s %s", Node.head->songhead->time, Node.head->songhead->song.name);
each time you do this, you need to add the song to the end of some linked list.
One thing you will need to implement is the detection of when artist1 becomes artist2. This is when you add a new artist to the tree.
Here's a bit more code
Code:
// appends a song to the end of a song list
// the return result is the new head of the list
// which only really matters when the list is initially empty
SONGPTR append_song_list ( SONGPTR head, SONGNODE data ) {
SONGPTR newnode = malloc( sizeof(SONGNODE) );
*newnode = data;
newnode->next = NULL;
if ( head == NULL ) {
head = newnode;
} else {
SONGPTR temp = head;
while ( temp->next != NULL ) {
temp = temp->next;
}
temp->next = newnode;
}
return head;
}
// a binary tree sorted by artist name
// follow left/right branches until a 'leaf' is found
// then add the new node at that point
ARTISTPTR insert_artist_tree ( ARTISTPTR tree, ARTIST data ) {
if ( tree == NULL ) {
ARTISTPTR newnode = malloc( sizeof(ARTIST) );
*newnode = data;
newnode->leftchild = NULL;
newnode->rightchild = NULL;
return newnode;
} else
if ( strcmp( data.artistname.name, tree->artistname.name ) < 0 ) {
return insert_artist_tree( tree->leftchild, data );
} else {
return insert_artist_tree( tree->rightchild, data );
}
}