append in C
typedef struct node {
int val;
struct node *next;
} NODE;
typedef NODE *NODE_PTR;
NODE_PTR cons(int val, NODE_PTR l){
NODE_PTR np;
np = (NODE_PTR)malloc(sizeof(NODE));
np->val = val;
np->next = l;
return np;
}
NODE_PTR append(NODE_PTR l1, NODE_PTR l2){
if (l1==NULL) return l2;
return cons(l1->val,append(l1->next,l2));
}
Previous slide
Next slide
Back to first slide
View graphic version