struct songs
{
char* name[MAX];
double length;
struct songs *next;
};
typedef struct songs songs;
struct albums
{
char* title[MAX];
int year;
char* singerName[MAX];
songs songs;
struct albums *next;
};
struct albums *head = NULL;
struct albums *curr = NULL;
struct songs *bas=NULL;
struct songs *current=NULL;
두 번째 부분은 모든 앨범의 목록을 보유하고 있습니다. 첫 번째 부분에는 노래 목록이 있습니다. 앨범에는 노래가 있습니다. 이 부분은 마지막으로 album.And을 추가 사용중첩 된 LinkedList in c
void add(char albumTitle[],char singerName[], int releaseYear)
{
struct albums *temp;
temp=(struct albums *)malloc(sizeof(struct albums));
strcpy(temp->title, albumTitle);
temp->year=releaseYear;
strcpy(temp->singerName, singerName);
if (head== NULL)
{
curr=head=temp;
head->next=NULL;
curr->next=NULL;
}
else
{
curr->next=temp;
curr=temp;
}
printf("Done\n");
}
,
void addSong(char albumTitle[],char songName[], double songLength)
{
struct albums *temp;
temp=(struct albums *)malloc(sizeof(struct albums));
temp=head;
struct songs *tempsong;
tempsong=(struct songs *)malloc(sizeof(struct songs));
tempsong=bas=current;
while(temp!=NULL)
{
if(!(strcmp(temp->title, albumTitle)))
{
bas=temp->songs;
strcpy(tempsong->name,songName);
tempsong->length=songLength;
if (bas== NULL)
{
bas=tempsong;
bas->next=NULL;
current->next=NULL;
}
else
{
current->next=tempsong;
current=tempsong;
}
break;
}
else
{
temp= temp->next;
}
}
}
이 부분이 part.How에 내가 큰 노래를 추가 할 수있다 albums.My 문제에 대한 노래를 추가 할 필요가 linkedlist? 의견을 보내 주셔서 감사합니다.
https://sourceware.org/gdb/current/onlinedocs/gdb/ 그냥 당신이'숯불 * 이름은 [MAX는]''MAX' 문자열, MAX' '길이없는 문자열의 배열입니다, 알려. –
Okey @ BrendanLong. 감사합니다. – Semih