Hi,
i'm new in c, I have a problem with a Linked list maybe you can help me
I made a linked list, and it's working fine, but i have a problem trying to access to an item using an index
This is my structure and functions (i'll put a red note where i think the error is):
Code:
typedef struct node{
int a;
int b;
struct nodo *next;
}List;
//insert function:
List *insert(List **lst, int a, int b){
assert(lst!=NULL);
List *node=malloc(sizeof(List));
node->next=*lst;
*lst=node;
node->a=a;
node->b=b;
return *lst;
}
List **get(List **lst, int index){
int i=0;
while ( (*lst != NULL) && (i< index) ){
lst=&(*lst)->next;
i++;
}
if (i==index){
return lst;
}else{
return NULL;
}
}
//im calling the get from other function using this:
int valuea=get(&alist,10)->a;
the error i'm receiving is:
error: request for member 'a' in something not a structure or union
I'll appreciate your help!
Thank you!