I have 2 structs using pointers to form a linked list.
typedef struct {
char *text;
int count;
} *Item;
typedef struct node {
Item item;
struct node *next;
} *link;
Im trying to create a bunch of operations over this type but I'm having a lot of problems with this particular function.
error: request for member ‘text’ in something not a structure or union strcpy(new->item->text, buffer->text);
error: request for member ‘text’ in something not a structure or union new->item->text = (char*) malloc(sizeof(char)*(strlen(buffer->text)+1));
Basically the error is on the buffer->text pass, but I've been messing around with it for the past hour and can't seem to find what's wrong with it. I'm probably missing something obvious but I can't wrap my hear around it anymore.
link new_item(Item* buffer) {
link new = (link) malloc(sizeof(struct node));
new->item->text = (char*) malloc(sizeof(char)*(strlen(buffer->text)+1));
strcpy(new->item->text, buffer->text);
new->item->count = 1;
new->next = NULL;
return new;
}