So say I have a node from a doubly linked list
typedef struct node
{
struct node *pPrev;
struct node *pNext;
struct record *data;
}Node;
and the following struct named record with a struct within that named songlength
typedef struct record
{
char *artist;
char *album;
char *song;
char *genre;
struct songlength *length;
int played;
int rating;
}Record;
typedef struct songlength
{
int mins;
int secs;
}SongLength;
How would I go about allocating memory for something like this. I know how to do a simple malloc/make node for a single int in each node of a list.
Node *makeNode (int newData)
{
Node *pMem = NULL;
pMem = (Node *) malloc (sizeof (Node));
pMem -> data = newData;
pMem -> pNext = NULL;
return pMem;
}
At the current state I have no idea how to do this. As all my attempts result in a big mess of mixed up memory.
pMem -> data = newDatato work when the type ofpMem -> dataisstruct record*and the type ofnewDataisint??? - barak manos