Hi, I am still having problems with my linked list of linked lists problem I posted last month, here is the linking function I have devised:
Code:
void lnk_C_and_H(Holiday *pHoliday, Customer *pCustomer, int nHolidays, int nCustomers)
{
pCustomer = pHead;
for(int i = nCustomers; i>0; i--)
{
pHoliday = Head;
for(int j = nHolidays; j>0; j--)
{
if(strcmp(pHoliday->Holiday_code,pCustomer->Holiday_code))
{
pHoliday->pCustomer_lst = new Customer;
pHoliday->pCustomer_lst = pCustomer;
add_Customer(pHoliday->pCustomer_lst);
break;
}
pHoliday = pHoliday->next;
}
pCustomer = pCustomer->pNext;
}
}
also here is the add_Customer() function:
Code:
void add_Customer(Customer *pCustomer)
{
if(pHead == NULL)
{
pHead = pCustomer;
pCustomer->pPrev = pHead;
pCustomer->pNext = pHead;
}
else
{
pCustomer->pPrev = pHead->pPrev;
pHead->pPrev->pNext = pCustomer;
pCustomer->pNext = pHead;
pHead->pPrev = pCustomer;
}
}
and here are the 2 structures:
Code:
struct Customer
{
string fName;
string lName;
char Holiday_code[5];
Customer *pNext;
Customer *pPrev;
}*pHead, *pHead2, *pCustomer;
struct Holiday
{
char Holiday_code[5];
string location;
string destination;
string place_of_stay;
double price;
Customer *pCustomer_lst;
Holiday *next;
Holiday *prev;
}*Head, *pHoliday;
What I did was first create a linked list of customers and holidays, and then i tried to link them and (create I beleive) a third linked list of customers ona specific holiday, well it didnt work at all, I am completely perplexed by this problem and am not even sure if my methods are correct as I dont think I am suppose to make a 3rd linked list (am I?).
Any help on this matter would be greatly apreciated.