// this is program designed to create Cd data base
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//=============================================
//LINKED LIST USED FOR CREATING THE DATABASE CD
//=============================================
struct CD_type_node
{
int CDnum;
char title[20];
int CDcount;
struct CD_type_node* next;
};
struct Artist_type_node // to create a linked list of CD's
{
struct CD_type_node CD_data;
char Artist_name[20];
struct Artist_type_node* next;
};
// ===================
//FUNCTION PROTOTYPES
//====================
struct CD_type_node* insert(struct CD_type_node* temp);
struct CD_type_node* delete_CD(struct CD_type_node*temp1);
int main()
{
struct CD_type_node* mylist; // this points to the first node of the linked list
mylist = (struct CD_type_node*)malloc(sizeof(struct CD_type_node)); // allocate space for the CD database linked list
int i;
for (i = 0; i < 100; i++)
{
struct Artist_type_node;
}
printf(" 1) Stock new CD\n 2) print details of CD\n 3)search CD\n 4) Sell a CD\n 5) Quit\n");
int menu = 5;
while (menu >= 1 && menu <= 5)
{
scanf("%d", &menu);
if (menu == 1)
{
mylist = insert(mylist);
}
if (menu == 2)
{
printf("works2");
}
if (menu == 3)
{
printf("works3");
}
if(menu == 4)
{
printf("works4");
}
if (menu == 5)
{
printf("works5");
}
if (menu > 5 || menu < 1)
{
printf("invalid range..... put a number between 1-5\n");
scanf("%d", &menu);
}
}
free(mylist);
return 0;
}
struct CD_type_node* insert(struct CD_type_node* temp)
{
struct CD_type_node* CDlist = temp;
int num, count;
char name[20], artist[20];
printf(" 1) Aritst name: \n 2) CD title: \n 3) CD number: \n 4) The Amount to be stocked: \n");
scanf("%s",artist);
CDlist->Artist_name[20] = artist[20];
scanf("%s", name);
CDlist->title[20] = name[20];
scanf("%d", &num);
CDlist->CDnum = num;
scanf("%d", &count);
CDlist->CDcount= count;
printf("%s\n %d\n %d\n", CDlist->title, CDlist->CDnum, CDlist->CDcount);
}
this is partial of the project:
1) Create a CD_type_node structure having the following fields:
CD number
CD title
CD count
A pointer to CD_type_node to point to next CD.
2) Create a Artist_type_node structure having the following fields:
Artist’s name
A pointer to a CD_type_node, to enable you to create a linked list for CDs.
3) In your main, create an array of type Artist_type_nodes that can store up to 100 elements.
Thus, your database will be an array of 100 Artists, where each Artist has a list of CDs. Basically, each Artist’s name and a pointer to the list of CD’s will be stored in the Artist_Array.
------------------------------
when i compile this is what it tells me: struct CD_type_node has no element Artist_name
how do i make the correct linked list and how do i create the array