I have a struct:
Code:typedef int DATA; typedef struct node { struct node *next; DATA digit; } NODE; typedef struct { struct node *head; int size; // number of elements in the list } LIST_HEAD;
I write reverseList fuction to reverses the order of the elements in the list, return a pointer to head of the reversed list.
Everything seem works fine, but I get the [Warning] return from incompatible pointer type at the return line. Please help to indicate my problem in this code. Thank you.
Code:LIST_HEAD *reverseList(LIST_HEAD *list) NODE *p,*q,*r; p=list->head; q=NULL; while(p!=NULL) { r=q; q=p; p=p->next; q->next=r; } p = q; list->head=p; return p; //error here }