I've searched for the forums and found many solutions to this problem. While solving it with my program has proven to be very difficult, the ones I did fix just created more errors.
What I'm doing is created a linked list. Each node in the linked list contains a number from 0 - 9.
This function works fine:
Code:
void emptyList(LIST_HEAD *list){
list->head = NULL;
list->size = 0;
}
However this does not, I get the 'Request for member x in something not in a struct or union' error here.
Code:
NODE *insertFirst(LIST_HEAD *list, DATA digit){
NODE node;
node.digit = digit;
if (list.head == NULL){
node.next = NULL;
list.head = node;
}else{
node.next = list->head;
list->head = node;
}
list->size = list->size + 1;
return node;
}
My first question is how to return addresses to dynamic variables (or variables that are created every time the function is run) and not get a warning that its a local variable. I also have issues with the return statement with incompatible types. In any other language this would be easy for me to fix but for some reason this has me by the 'short hair and curlies' >.<
Here is another example:
Code:
LIST_HEAD listHead;
LIST_HEAD *createList(void){
return &listHead;
}
This works but it doesn't have the intended use - how can I create an object of type LIST_HEAD (my own struct) and return the address to it without it being local variable?
Any help is GREATLY appreciated
Thanks,
Lang