Any hints or insights are greatly appreciated!
Here are parts of the code:
The struct:
struct CDNode
{
int ID; //För att hålla koll på noderna
CDNode *next;
CDNode *prev;
char titel[80];
char artist[80];
int speltid, antalspr;
};
The function to add a node, "laggtill":
void laggtill(CDNode *NewNode)
{
if (Head == NULL && Tail == NULL) //Fallet tom lista
{
Head = NewNode;
Tail = NewNode;
}
else //Icke-tom
{
NewNode->prev = Tail;
Tail->next = NewNode;
Tail = NewNode;
}
}
My feeble attempt of user input:
case 'A':{
CDNode *Node = new CDNode;
Node->prev = NULL;
Node->next = NULL;
if (Head == NULL && Tail == NULL)
{
Node->ID = 1;
}
//cout << Node->ID;
else
{
Node->ID = Node->prev->ID + 1;
}
cout << "Enter Title: ";
char title[80];
cin.getline(title, 80);
strcpy(Node->titel, title);
cout << endl << "Enter Artist: ";
char Artist[80];
cin.getline(Artist, 80);
strcpy(Node->artist, Artist);
cout << endl << "Enter Tracks: ";
cin >> Node->antalspr;
cout << endl << "Enter Length: ";
cin >> Node->speltid;
laggtill(Node);
//Kolla Node->prev->ID if =0 etc...
break;
}

New Topic/Question
Reply




MultiQuote





|