Hello! I have this problem with creating a linked list inside a linked list. Think of it as recording a list of customers, and at the same time, recording a list of items they bought individually. I tend to think that I might lose the head node and it's probably what's making me crazy. Here's my code with initializing the LL inside an LL.

typedef struct custNode
{
	char name[100];
	typedef struct dish
	{
		char dishname[100];
		int price;
		int quantity;
		dish *NEXT;
	};
	dish *head;
	custNode *NEXT;
};

P.S. My professor told me that I might want to try initializing the pointer head inside the structure, but it appears that it's impossible. Thank you for the help!

With power comes responsibility. Accept it and move on.

BTW: good first post! code tags, question, pertinent code, wonderful.

BTW: you have declared user defined types that could be used in linked lists. You haven't actually initialized anything in the code you've posted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.